I am starting a new thread for this one, will try to be as specific as possible.
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.
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.
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;
}
And for what it is worth, running a Centos 5.5 server to create the documents. Thank you in advance.
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;
}
*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.
Thank you.
You can render Chinese character in your PDF document by using
cid0jp font in TCPDF.
For your reference :-
PHP Code :-
http://www.tcpdf.org/examples/example_038.phps
Generated PDF :-
http://www.tcpdf.org/examples/example_038.pdf
Please ensure file cid0jp.php should be in font directory.
tcpdf/fonts/cid0jp.php