PDF from PHP
#71 Henry, Thursday, 08 July 2010 3:35 PM (Category: Web Development)
(Tags: php pdf)

Last year I needed to create PDF files from PHP web pages. I was running a very old version of PHP and could not get anything going. I recently upgraded the webserver, and now have the latest Apache and PHP, so creating PDFs became an issue again.

I started working through the PHP manual's PDF pages, where they use PDFLib Lite. I failed. I could get the PDFLib Lite library installed, but I failed to understand and implement the pdflib PHP interface. So I gave up.

At the bottom of that manual, someone recommended using FPDF - FreePDF. I tried it. It basically consists of a single PHP file that defines a PDF class, and a directory of fonts. You include the PHP file, and just go. It's simple, it works, I created my PDF report in about half an hour, and the end user was ecstatic.

On their website they have some brief tutorials, and a whole bunch of scripts to create some very fancy PDFs. It's a very nice product.