Import pages from existing PDF documents and use them as templates in FPDF

Free PDF Document Importer

FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF, which was developed by Olivier Plathey. Apart from a copy of FPDF, FPDI does not require any special PHP extensions.

As of version 1.2.1 FPDI can also be used with TCPDF.

FPDI is published under the MIT license as of version 1.6 (Versions before were released under the Apache Software License, Version 2.0).

The usage is very easy: open the document, put a page into a template, and use it like an image!


$pdf = new FPDI();

$pageCount = $pdf->setSourceFile("Fantastic-Speaker.pdf");
$tplIdx = $pdf->importPage(1, '/MediaBox');

$pdf->useTemplate($tplIdx, 10, 10, 90);



FPDI is the first PHP/PDF script by Setasign. 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 a kind of template feature to FPDF: FPDF_TPL. This class is a requirement for FPDI and can be downloaded in the downloads area as well. It is bundled in FPDI as of version 1.5.

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.

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 the MIT 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!

Do you like this product?

Then it would be awesome, if you‘d recommend it to your friends!