PHP & PDF Solutions

 

Info

It's FREE!

The 'F' in FPDI stands for 'free': you may use it for any kind of project and adapt it to your needs -the license conditions of ASL 2.0 are met nevertheless.

donate via PayPal


PDF Documents > 1.4

Do you need support for PDF documents with a version higher than 1.4? Check out the new FPDI PDF-Parser!


About FPDI

Setasign's first PHP/PDF script: FPDI. Inspired by an article of Marco Tabini in the 'php|architect' magazine, Setasign wrote the first version of FPDI in 2004.

It is based on another extension for FPDF that adds FPDF_TPL - a kind of template feature - to FPDF. This feature can be downloaded in the downloads area.

FPDF_TPL does not only prepare FPDF for FPDI, but offers many other advantages:

  • data of templates are included in a PDF document only once
  • less memory usage
  • less generation time
  • smaller PDF files
  • recursive template support (use of templates in templates)

Examples of use:

  • Header generation
  • Grids for large tables over several pages
  • Table headers
  • write behind or in front of a template
  • resize a template after creation
  • etc.

Compatibility with TCPDF

As of version 1.2.1 FPDI can be used with TCPDF - a derivate of FPDF.

We integrated the support into the main classes and used a kind of bridge class for remapping TCPDF to FPDF in which we made some essential changes. The remapping is an automated process and is related to the available, loaded class. If you load (require) FPDF first, FPDF_TPL will extends FPDF. If you load TCPDF first, the bridge class will extend TCPDF and FPDF_TPL will extend the bridge class. That way we were able to use one class for both versions.

FPDF_TPL itself is not fully compatible! Simple templates can be created, but things like HTML are not compatible.

There are also limitation for TCPDF: As TCPDF writes some content to the begining of a content stream, border- and background gets behind a template, while the text still stays in front of it.

What FPDI can do and what FPDI cannot do

FPDI extracts and imports single pages of existing documents into FPDF. The resulting PDF created by FPDF/FPDI is a completely new document. Please don't misunderstand: with FPDI you cannot edit a PDF.

FPDI and dynamic content

FPDI is unable to import dynamic parts of an existing document, like form fields, links, or any other available page annotation. While importing pages with such elements, the information becomes lost as it is not a part of a page's content stream.

FPDI and protected/encrypted documents

The FPDI standard version does not support the import of protected PDF files. But you can of course generate protected PDF files with the FPDI_Protection-Class.

Additionally, Setasign offers a commercial extension - FPDI_Protection_128_Pro - that provides the opportunity to import pages of encrypted PDF documents, and encrypt the resulting documents with up to 128bits.