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







#1 by Norbert Mocsnik - April 28th, 2008 at 19:22
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!
#2 by gedrox - April 29th, 2008 at 14:33
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.
#3 by Shaun - May 8th, 2008 at 17:28
The Zend_PDF class is very good for doing these types of things too!
#4 by admin - May 13th, 2008 at 10:12
Shaun: I’ve not seen that, but I will check it out. Thanks
#5 by Joel - July 20th, 2008 at 23:39
Brilliant! You just saved me a good few hours work. Thanks
#6 by Jan - September 11th, 2008 at 22:09
I just want to say that a new version of FPDI is up: 1.2.1 which is compatible with TCPDF as of now.
Cheers!
Jan
#7 by jQuery Howto - April 22nd, 2009 at 13:22
Great article. Exactly what I wanted!
Thanks for saving my day
#8 by Tarun Patel - October 10th, 2009 at 11:08
Thank You So Much……….
I was looking for this code since last 2 Days..
Once again Thanx..