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.

October 6th, 2006 | PHP, Programming | 0 Comments

A Decent JavaScript Calendar

There probably isn’t a web app on earth that doesn’t require some kind of date input. Everyone has their own way of handling this: dropdown menus, a simple text box, multiple text boxes or the dreaded popup calendar.

Most popup calendars are either absolute garbage or too complex.

The Fuushikaden calendar, written by Tan Ling Wee in December of 2001, is probably the best answer to this problem I’ve seen. The calendar pops in the page instead of a new window and can be customized with CSS. It’s very nicely done.

Unfortunately, it’s nearly impossible to find online anymore. I only dug up one good URL: http://www.theopensourcery.com/jscalendarx.htm that explains things in any kind of detail. While all that detail is nice, the site doesn’t have the code (and images) readily available for download. You have to do a bit of digging. Internet.com’s JavaScript site used to have a page for it but that’s gone 404.

The developer of this calendar has officially gone AWOL from the web for a few years now. The copy of the Fuushikaden calendar I use is so heavily modified and trimmed for my own use at this point that I’d rather find the original.

If anyone knows of a site that has the original code and images of this calendar let me know. In the meantime I’m going to keep looking.

October 5th, 2006 | JavaScript, Programming | 0 Comments