Generate PDF from HTML PHP Generate PDF from HTML PHP php php

Generate PDF from HTML PHP


mpdf is another option that you could try.


EDIT :Found another solution for it, TCPDF is a FLOSS PHP class for generating PDF documents. Looks more dominating library.

"PRINCEXML" is a good library (not completely free now).

Others:

If your meaning is to create a PDF file from PHP, pdflib will help you (as some other suggested).

Else, if you want to convert an HTML page in PDF via PHP, you'll finda little trouble outta here.. For three years I have been trying to do it as best as Ican.

So, the options I know are:

HTML2PS: same of DOMPDF, but this one convert first in .ps(Ghostscript), then, in whatever format you need (PDF, JPEG, PNG). Forme it is a little better than dompdf, but I have the same speed problem.. Oh,it has better compatibility with CSS.

Those two are PHP classes, but if you can install some software on theserver, and access it through passthru() or system(), have a look atthese too:

wkhtmltopdf: based on webkit (safari's wrapper), is really fast andpowerful... It seem like it is the best one (atm) for converting HTML pages to PDF on the fly, taking only two seconds for a three pages XHTML documentwith CSS 2. It is a recent project. Anyway, the Google Code page is oftenupdated.

htmldoc: this one is a tank, it really never stops orcrashes... The projectseems to have died in 2007, but anyway if you don't need CSS compatibilitythis can be nice for you.

** Thumbs Up For Strae.


If I understand your needs correctly I don't think any PHP-PDF class would do that.

Mostly you could insert only text and images to a PDF file, so if you would want something that looks like an HTML element you would need to insert it as an image.

Usually just putting HTML doesn't mean all your elements would stay intact in the PDF . (Different world, after all)