PHP & PDFs
I’ve been meaning to write about making PDF files with PHP for the last week. Then today Jonathan Snook posted a link to a Zend article on PDF generation that uses only PHP and no external forces. Now I’ll throw my two cents in.
It’s an ok solution but there are some other ways to go for those of you not afraid to install some server-side programs, run third-party libraries or are looking for a free alternative to PDFlib.
FPDF
I’ll start with my personal preference to this problem. FPDF gives you total control of your PDF layout with some pretty easy to learn functions. It doesn’t require any additional software to run. You just upload the library to your server, include a file in your script and away you go. The downside to FPDF is that every piece of the PDF must be layed out yourself in code. There is no HTML converter packaged with FPDF.
HTML_ToPDF
HTML_ToPDF takes standard HTML ouput from either a file or an output buffer and turns it into a PDF with pretty accurate results. The secret behind HTML_ToPDF is that it is essentially a wrapper for two command-line programs. You need to be able to correctly install html2ps and ps2pdf before you can get HTML_ToPDF to work.
For a good read on HTML_ToPDF check out this article: MS Windows (and HTML_toPDF) made me a masochist.
HTML 2 PDF
HTML 2 PDF runs in the same way HTML_ToPDF works by taking standard HTML and converting it into a PDF document for you. The difference is that HTML 2 PDF runs off of the above mentioned FPDF library so it doesn’t require any difficult server side installations. The main problem for me with this library is its lack of support for nested tables. As unhip as nested tables are with the Web 2.0 Elite, HTML 2 PDF not supporting them is a deal breaker for me.










No Comments
Leave a comment...