search
Homephp教程php手册制作中文(繁简)的PDF

中文

有人还为无法用php_pdf做中文的pdf烦恼吧..
PHP_PDF套件在这边抓取,记得重新编译哦。用现成的会有MARK。
http://www.pdflib.com/pdflib/index.html

这是php_pdf配合Iconv转UTF-16做的简易制作中文PDF的范例。
此部份不包含排版。有空弟在写另外一个排版范例。

 
<code><font color="#000000"><font color="#0000bb"></font><font face="新宋体"><font color="#007700"><br></font><font color="#0000bb">$pdf </font><font color="#007700">= </font><font color="#0000bb">pdf_new</font></font><font face="新宋体"><font color="#007700">();<br><br></font><font color="#0000bb">pdf_open_file</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"./test.pdf"</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_set_info</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"Creator"</font><font color="#007700">, </font><font color="#0000bb">iconv</font><font color="#007700">(</font><font color="#dd0000">"BIG5"</font><font color="#007700">,</font><font color="#dd0000">"UTF-16"</font><font color="#007700">,</font><font color="#dd0000">"小企鹅"</font></font><font face="新宋体"><font color="#007700">));<br><br></font><font color="#0000bb">pdf_begin_page</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">595</font><font color="#007700">, </font><font color="#0000bb">842</font></font><font face="新宋体" color="#007700">);<br></font><font face="新宋体"><font color="#ff8000">## BOOKMARK要用UTF-16的UNICODE哦<br></font><font color="#0000bb">$Parent</font><font color="#007700">=</font><font color="#0000bb">pdf_add_bookmark</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">Iconv</font><font color="#007700">(</font><font color="#dd0000">"BIG5"</font><font color="#007700">,</font><font color="#dd0000">"UTF-16"</font><font color="#007700">,</font><font color="#dd0000">"繁体中文"</font></font><font face="新宋体"><font color="#007700">));<br></font><font color="#0000bb">pdf_add_bookmark</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">Iconv</font><font color="#007700">(</font><font color="#dd0000">"BIG5"</font><font color="#007700">,</font><font color="#dd0000">"UTF-16"</font><font color="#007700">,</font><font color="#dd0000">"字体一"</font><font color="#007700">),</font><font color="#0000bb">$Parent</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">$font </font><font color="#007700">= </font><font color="#0000bb">PDF_findfont</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"MHei-Medium"</font><font color="#007700">, </font><font color="#dd0000">"ETen-B5-H"</font><font color="#007700">, </font><font color="#0000bb">0</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">PDF_setfont</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">$font</font><font color="#007700">, </font><font color="#0000bb">14</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_show_xy</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"海南搏浪岛浪搏南海"</font><font color="#007700">, </font><font color="#0000bb">50</font><font color="#007700">, </font><font color="#0000bb">750</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_end_page</font><font color="#007700">(</font><font color="#0000bb">$pdf</font></font><font face="新宋体"><font color="#007700">);<br><br><br></font><font color="#0000bb">pdf_begin_page</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">595</font><font color="#007700">, </font><font color="#0000bb">842</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_add_bookmark</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">Iconv</font><font color="#007700">(</font><font color="#dd0000">"BIG5"</font><font color="#007700">,</font><font color="#dd0000">"UTF-16"</font><font color="#007700">,</font><font color="#dd0000">"字体一"</font><font color="#007700">),</font><font color="#0000bb">$Parent</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">$font </font><font color="#007700">= </font><font color="#0000bb">PDF_findfont</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"MSung-Light"</font><font color="#007700">, </font><font color="#dd0000">"ETen-B5-H"</font><font color="#007700">, </font><font color="#0000bb">0</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">PDF_setfont</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">$font</font><font color="#007700">, </font><font color="#0000bb">14</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_show_xy</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"白沙明月夜月明沙白"</font><font color="#007700">, </font><font color="#0000bb">50</font><font color="#007700">, </font><font color="#0000bb">750</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_end_page</font><font color="#007700">(</font><font color="#0000bb">$pdf</font></font><font face="新宋体"><font color="#007700">);<br><br></font><font color="#0000bb">pdf_begin_page</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">595</font><font color="#007700">, </font><font color="#0000bb">842</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">$Parent</font><font color="#007700">=</font><font color="#0000bb">pdf_add_bookmark</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">Iconv</font><font color="#007700">(</font><font color="#dd0000">"BIG5"</font><font color="#007700">,</font><font color="#dd0000">"UTF-16"</font><font color="#007700">,</font><font color="#dd0000">"简体中文"</font></font><font face="新宋体"><font color="#007700">));<br></font><font color="#0000bb">pdf_add_bookmark</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">Iconv</font><font color="#007700">(</font><font color="#dd0000">"BIG5"</font><font color="#007700">,</font><font color="#dd0000">"UTF-16"</font><font color="#007700">,</font><font color="#dd0000">"字体一"</font><font color="#007700">),</font><font color="#0000bb">$Parent</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">$font </font><font color="#007700">= </font><font color="#0000bb">PDF_findfont</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"STSong-Light"</font><font color="#007700">, </font><font color="#dd0000">"GBK-EUC-H"</font><font color="#007700">, </font><font color="#0000bb">0</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">PDF_setfont</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#0000bb">$font</font><font color="#007700">, </font><font color="#0000bb">14</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_show_xy</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"奻漆赻懂厄厄懂赻漆奻"</font><font color="#007700">, </font><font color="#0000bb">50</font><font color="#007700">, </font><font color="#0000bb">750</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_show_xy</font><font color="#007700">(</font><font color="#0000bb">$pdf</font><font color="#007700">, </font><font color="#dd0000">"笢刓甜菱豪豪菱甜刓笢"</font><font color="#007700">, </font><font color="#0000bb">50</font><font color="#007700">, </font><font color="#0000bb">650</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_end_page</font><font color="#007700">(</font><font color="#0000bb">$pdf</font></font><font face="新宋体" color="#007700">);<br><br></font><font face="新宋体"><font color="#ff8000">/*<br>    中文 encoding 的部分<br>    { "GB-EUC-H",       cc_simplified_chinese },<br>    { "GB-EUC-V",       cc_simplified_chinese },<br>    { "GBpc-EUC-H",     cc_simplified_chinese },<br>    { "GBpc-EUC-V",     cc_simplified_chinese },<br>    { "GBK-EUC-H",      cc_simplified_chinese },<br>    { "GBK-EUC-V",      cc_simplified_chinese },<br>    { "UniGB-UCS2-H",   cc_simplified_chinese },<br>    { "UniGB-UCS2-V",   cc_simplified_chinese },<br><br>    { "B5pc-H",         cc_traditional_chinese },<br>    { "B5pc-V",         cc_traditional_chinese },<br>    { "ETen-B5-H",      cc_traditional_chinese },<br>    { "ETen-B5-V",      cc_traditional_chinese },<br>    { "ETenms-B5-H",    cc_traditional_chinese },<br>    { "ETenms-B5-V",    cc_traditional_chinese },<br>    { "CNS-EUC-H",      cc_traditional_chinese },<br>    { "CNS-EUC-V",      cc_traditional_chinese },<br>    { "UniCNS-UCS2-H",  cc_traditional_chinese },<br>    { "UniCNS-UCS2-V",  cc_traditional_chinese },<br>    汉字型的部分<br><br>    "MHei-Medium",<br>    "MSung-Light",<br>    "STSong-Light",<br><br>*/<br><br></font><font color="#0000bb">pdf_close</font><font color="#007700">(</font><font color="#0000bb">$pdf</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">pdf_delete</font><font color="#007700">(</font><font color="#0000bb">$pdf</font></font><font face="新宋体"><font color="#007700">);<br></font><font color="#0000bb">?></font></font></font>



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.