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: , ,

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DZone
  • Live
  • Slashdot

6 Responses to “Populate PDF templates with PHP / FPDF / FPDI”

  1. Norbert Mocsnik Says:

    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. Skylog » Blog Archive » links for 2008-04-29 Says:

    […] Populate PDF templates with PHP / FPDF / FPDI (tags: php) […]

  3. gedrox Says:

    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.

  4. Eirik Hoem’s Blog: Populate PDF templates with PHP / FPDF / FPDI | Development Blog With Code Updates : Developercast.com Says:

    […] Hoem recently pointed out two libraries that can be used in PHP to generate PDF files dynamically - FPDF and FPDI. Ever […]

  5. Shaun Says:

    The Zend_PDF class is very good for doing these types of things too!

  6. admin Says:

    Shaun: I’ve not seen that, but I will check it out. Thanks :)

Leave a Reply