Populate PDF templates with PHP / FPDF / FPDI
April 28th, 2008
Ever wanted to generated PDF documents on the fly with PHP? Perhaps populate a standard contract with a customers name and address? FPDF and FPDI are two neat libraries which greatly helps when working with PDF files. FPDF is the main library for handling PDF files, while FPDI lets your import existing PDF documents into the FPDF documents. In the code sample I’ve prepared here I’m importing a PDF template document, writing some information to the document, then sending it to the “customer”. FPDF offers several neat ways to expose the generated document, such as a stream to the browser, a string, or just storing it to file. You can download PDF Sample code to test it.
Be sure to head on over to the FPDF site and FPDI site for more information on these two libs.
Related posts:
Generated PDFs over HTTPS with Internet Explorer
Technorati Tags: PHP, PDF, Frameworks







April 28th, 2008 at 7:22 pm
Thanks! FPDI is just what I’ve been looking for when your post popped up out of nothingness on the main page at planet-php. Great timing!
April 29th, 2008 at 7:32 am
[…] Populate PDF templates with PHP / FPDF / FPDI (tags: php) […]
April 29th, 2008 at 2:33 pm
It’s suitable for small needs, but for serious pdf documents with unicode, floating texts and tables pdflib is the only solution I have found so far. Still you must pay for it.
May 8th, 2008 at 5:24 pm
[…] Hoem recently pointed out two libraries that can be used in PHP to generate PDF files dynamically - FPDF and FPDI. Ever […]
May 8th, 2008 at 5:28 pm
The Zend_PDF class is very good for doing these types of things too!
May 13th, 2008 at 10:12 am
Shaun: I’ve not seen that, but I will check it out. Thanks