PDF Export in php

Learner picture Learner · May 8, 2012 · Viewed 69.5k times · Source

Is there any possibility to write huge data in pdf without changing any ini modifications with less executing time..?

Currently I'm using tcpdf plugin.

Answer

Somnath Muluk picture Somnath Muluk · Aug 6, 2012

If your intention is to create a PDF from PHP, pdflib will help you.

Otherwise, if you want to convert an HTML page to PDF via PHP, you'll find a little trouble outta here.

So, the options I know are:

DOMPDF : PHP class that wraps the HTML and builds the PDF. Works good, customizable (if you know PHP), based on pdflib, and, if I remember correctly, it takes even some CSS. Bad news: slow when the HTML is big or very complex.

HTML2PS: same as DOMPDF, but this one converts first in .ps (GhostScript), then, in whatever format you need (PDF, JPEG, PNG). For me it is a little better then DOMPDF, but have the same speed problem. Oh, better compatibility with CSS.

Those two are PHP classes, but if you can install some software on the server, and access it through passthru() or system(), give a look to these too:

wkhtmltopdf: based on WebKit (Safari's wrapper), it's really fast and powerful. Seems like it is the best one (at the moment) for HTML to PDF conversion on the fly, taking only 2 seconds for a 3 page XHTML document with CSS2. It's a recent project anyway, so the google.code page is often updated.

htmldoc : this one is a tank, it really never stops/crashes. The project seems dead, as of 2007, but if you don't need CSS compatibility this can be nice for you.

tcpdf - this is an enhanced and maintained version of fpdf. It has all the main Features of tpdf and it also has faster execution time with great output. For detailed tutorial on using the two most popular PDF generation classes: TCPDF and FPDF, please follow this link. I think you should continue using TCPDF.

See these posts also:

  1. Convert HTML + CSS to PDF with PHP?
  2. Which one is the best PDF-API for PHP?
  3. Export a html into PDF in PHP?
  4. Writing HTML with PHP variables to PDF file?
  5. How to convert html into pdf with php?
  6. Tool for exporting html as pdf
  7. Converting HTML in PHP File to PDF File