带有TCPDF的HTML2PDF无法在最终的PDF文档中呈现汉字

带有TCPDF的HTML2PDF无法在最终的PDF文档中呈现汉字

问题描述:

我正在为此启动一个新线程,将尝试尽可能具体.

I am starting a new thread for this one, will try to be as specific as possible.

这是我们销售人员应用程序的一部分,允许销售人员使用他们的联系信息自定义页面,在他们单击提交"后,将创建一个PDF页面,然后将其附加到较大文档的末尾.

This is a portion of an app for our sales people that allows them to customize a page with their contact information, after they hit submit, a PDF page is created which is then attached to the end of a larger document.

该文档的第一页也是根据其填写的相同表格动态创建的.他们按下提交后,将创建2个PDF文件,分别是首页和背面,然后将这两个页面都附加到一个较大的文档中,从而创建一个报告.

The first page of the document is also dynamically created from the same form that they fill out. After they press submit, 2 PDF files are created, a front page and a back page, then both pages are attached to a larger document creating a single report.

一切都很好,除非他们输入汉字,否则我得到的只是像这样的垃圾字符-(质釕俕蕕æμ•ç¨‹).甚至在与较大的文档合并之前,该文档仍然看起来像这样.

Everything works great unless they enter Chinese characters then all I get is garbage characters like this - (质釕俕试æμ•ç¨‹). The document still looks like this even before it is merged with the larger document.

我尝试了所有可能的情况(似乎),从使用Unicode字体到使用我自己创建的字体,再一一尝试尝试TCPDF文件夹中的每种字体.我完全不知所措,已经有一段时间了.我觉得我到过几乎所有提及TCPDF的网站.

I have tried every possible scenario (it seems) from using a Unicode font, to using my own created font and one by one trying each of the fonts in the TCPDF folder. I am at a total loss, and have been for some time now. I feel like I have been on just about every website that mentions TCPDF.

这是创建后页的代码,回到我最初使用的基本命令.我希望这是一个我想念的简单命令:

Here is the code that creates the back page, back to the basic commands I started with. I am hoping it is a simple command down here that I am missing:

require_once(dirname(__FILE__).'/html2pdf.class.php');
try
{
    $html2pdf = new HTML2PDF('L','LETTER','en', false, 'ISO-8859-15', array(mL, mT, mR, mB)); 
    $html2pdf->setDefaultFont('Arial');
    $html2pdf->writeHTML($html, isset($_GET['vuehtml']));

//Line below saves PDF to file
    $html2pdf->Output('created/'.$lastname[1].'_html2pdf.pdf', 'F');

}

catch(HTML2PDF_exception $e) {
    echo $e;

}

运行Centos 5.5服务器创建文档,这是值得的.预先谢谢你.

And for what it is worth, running a Centos 5.5 server to create the documents. Thank you in advance.

在使用HTML2PDF对这个问题进行了一些调查之后,我被告知字体arialuni.ttf应该支持我需要的所有字符.话虽如此,当我在下面显示的脚本中使用该字体时,HTML2PDF不会加载该字体.

After doing some investigation on this issue with HTML2PDF, I was told that the font arialuni.ttf should support all of the characters I need. With that being said, HTML2PDF will not load this font when I use it in my script seen below.

require_once(dirname(__FILE__).'/html2pdf.class.php');
try
{

    $html2pdf = new HTML2PDF('L','LETTER','en', false, '', array(mL, mT, mR, mB));      
    $html2pdf->pdf->AddTTFFont('ARIALUNI.TTF');
    $html2pdf->pdf->setFont('arialuni');
    $html2pdf->writeHTML($html, isset($_GET['vuehtml']));

    //Line below sends output to the screen only
    //$html2pdf->Output('exemple00.pdf');

    //Line below saves PDF to file
   $html2pdf->Output('created/'.$lastname[1].'_html2pdf.pdf', 'F');

}

catch(HTML2PDF_exception $e) {
    echo $e;

}

*我能想到的就是语法不是100%正确的.我已经运行过tt2fm和makefont来获取文件,但并不认为这些例程100%成功.

*All I can think is that the syntax is not 100% correct. I have ran the tt2fm and makefont to get the files but do not feel that those routines were a 100% successful.

请帮忙-我已经不停地研究这个问题了几个月了.我几乎准备好将其报废然后撞上门.

Please help - I have been working on this thing off and on for months. I am almost ready to just scrap it and hit the door.

谢谢.

您可以使用

cid0jp 字体.

供参考:-

PHP代码:-

http://www.tcpdf.org/examples/example_038.phps

生成的PDF:-

http://www.tcpdf.org/examples/example_038.pdf

请确保文件 cid0jp.php 应该位于字体目录中.

Please ensure file cid0jp.php should be in font directory.

tcpdf/fonts/cid0jp.php