TCPDF very slow generation of dynamic arabic PDF
I've been using a combination of nusoap & TCPDF to ping a web service and dynamically fill out a PDF with conte开发者_运维百科nt.
The PDF itself (in english) takes around 8-9 seconds to complete for about 36 pages, some of which include bar charts. I'd also like to note that due to the format that the data is received in, I am using "writeHTML" to present it on the PDF.
My major issue came around when I started trying to generate the same PDFs with arabic translations. I'm using the "Almohanad" font as described in the TCPDF examples, and the processing time jumped up to 2 minutes.
I've tried using the following fix (which caches font files) : http://www.bitrealm.net/2010/08/tcpdf-is-slow-here-is-the-solution/
Alas it did not seem to work (the ".CACHED" file didn't appear even though I gave the tcpdf file full user permissions)! I do have to mention that i needed to insert ob_clean() after the "require_once" section of my php file to avoid the following error:
"TCPDF error: Some data has already been output, can't send PDF"
I checked my php files for white space and found nothing out of place.
In conclusion, could anyone help me speed up the generation of the arabic PDF using TCPDF, or else recommend a quicker alternative?
Thanks for your time.
On the latest TCPDF version, the almohanad was replaced by aefurat and aealarabiya fonts.
The latest TCPDF version automatically convert fonts into TCPDF format using the addTTFfont() method, so you can easily add new arabic fonts as on the example below:
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = $pdf->addTTFfont('/path-to-font/FontName.ttf', 'TrueTypeUnicode', '', 96);
// use the font
$pdf->SetFont($fontname, '', 14, '', false);
Check also the http://projects.arabeyes.org website for alternative Arabic fonts and the http://www.tcpdf.org website for the new fonts guide.
Try mPDF as an alternative it is very easy to use and it amazingly supports RTL languages like Arabic, Hebrew, Farsi/Persian, Urdu and Pashto. And this is an example demonstrates that.
精彩评论