Rectangle 27 0

Which one is the best PDF API for PHP?


DOMPdf is the easiest way to make a pdf quickly. Like Mike said, feed it html and it outputs a pdf. Under the hood, it has the option to use either r&ospdf or pdflib as the rendering engine.

The Zend Framework's Zend_Pdf is really good. It's on par with pdflib in terms of control of output and complexity and is more portable because its a pure php solution. That said, its slower and uses more memory than pdflib. Pecl modules are always more efficient than a php solution.

Zend PDF has significant (performance issues if you embed PNGs with transparencies)[framework.zend.com/issues/browse/ZF-3392]. Also Zend PDF is a very bad tool for changing meta-data on 3rd party PDFs because it cannot handle anything close to the full PDF standard and it crashes. However, if you do not need these features Zend PDF works pretty well and has good UTF-8 support.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


If you call a single class with 24k lines of code "decent OO" you must be high. Check out my refactored version of FPDF for actual OOP : github.com/bubach/PdfBuilder

i just checked the tcpdf website and it does seem to support font subsetting and embedding. see the subset argument to the SetFont method tcpdf.org/fonts.php

personally i'd rather go with tcpdf which is an ehnanced and mantained version of fpdf.

tcpdf is missing critical features like font embedding and subsetting (important for asian languages).

tcpdf was having some issues when I used with urdu unicode fonts.

you didn't specify reasons - one huge one is Unicode support in tcpdf, which fpdf utterly lacks. tcpdf is also still actively maintained. and, it's also got a decent OO architecture. word to the wise: fpdf is basically an old thing that got superseded by tcpdf.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


Crushes sometimes in Firefox with connection reset. Haven't check with the other browsers though.

For detailed tutorial on using the two most popular pdf generation classes: TCPDF and FPDF.. please follow this link: PHP: Easily create PDF on the fly with TCPDF and FPDF

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


From the mpdf site: "mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements."

mpdf is superior to FPDF for language handling and UTF-8 support. For CJK support it not only supports font embedding, but font subsetting (so your CJK PDFs are not oversized). TCPDF and FPDF have nothing on the UTF-8 and Font support of mpdf. It even comes with some open source fonts as of version 5.0.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


I found it useful for designing invoices, receipts and simple prints etc. However the website itself says that pdfs generated from mpdf tend to be larger in size.

I found mpdf better than tcpdf in terms of html rendering. It can parse css styles much better and create pdf that look very similar to the original html.

mpdf even supports css things like border-radius and gradient etc.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


But there is a cons of using dompdf is that it doesn't work if you want to create multiple pdf at once or in a loop.

Personally I prefer to use dompdf for simple PDF pages as it is very quick. you simply feed it an HTML source and it will generate the required page.

however for more complex designs i prefer the more classic pdflib which is available as a pecl for PHP. it has greater control over designs and allows you do do more complex designs like pixel-perfect forms.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


17.0366 seconds to process 2000 PDF files using fPDF || 79.5982 seconds to process 2000 PDF files using tcPDF

The code used was as identical as possible and renders just a clean PDF file with no text. This is also using the latest version of each library as of June 22, 2011.

There are a number of performance enhancements that can massively improve the TCPDF speed (I went from 1 minute in creating a single file to about 0.5 seconds): tcpdf.org/performances.php

This is just a quick review of how fPDF stands up against tcPDF in the area of performance at each libraries most basic functions.

Those "enhancments" will work equally well with FPDF and won't really help in a benchmark. TCPDF is about 24 000 lines of code, while FPDF is about 2400 lines of code.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


I personally generate XSL:FO from PHP and use Apache FOP to convert it to PDF. Not a PHP-native solution, not very efficient either, but it works well even if you need to generate PDF with very complex layouts.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


I upvote for wkhtmltopdf, but especially when using a method like employing an outside converter PHP is not to blame for loss of speed. I would think that using wkhtmltopdf or prince from asp.net would be practically equally fast as from PHP (although I use asp.net). Sure, PHP doesn't have all the process control of .net, but I would bet it still works fast enough for most projects

PHP take many resources to convert html in pdf, imho, php is not the right language to do that (if you expect a large numbers of coversion or large files to convert)

There is also a drupal module using wkhtmltopdf :)

if you can install software on your server, i suggest you to use http://wkhtmltopdf.org/.

Note
Rectangle 27 0

Which one is the best PDF API for PHP?


But there is a cons of using dompdf is that it doesn't work if you want to create multiple pdf at once or in a loop.

Personally I prefer to use dompdf for simple PDF pages as it is very quick. you simply feed it an HTML source and it will generate the required page.

however for more complex designs i prefer the more classic pdflib which is available as a pecl for PHP. it has greater control over designs and allows you do do more complex designs like pixel-perfect forms.

Note