FPDI - Free PDF Document Importer

Latest Stable Version
Total Downloads
Latest Unstable Version

:heavy_exclamation_mark: This document refers to FPDI 2. Version 1 is deprecated and development is discontinued. :heavy_exclamation_mark:

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.

FPDI can also be used as an extension for TCPDF or
tFPDF, too.

Installation with Composer

Because FPDI can be used with FPDF, TCPDF or tFPDF we haven’t added a fixed dependency in the main
composer.json file. You need to add the dependency to the PDF generation library of your choice

To use FPDI with FPDF include following in your composer.json file:

    "require": {
        "setasign/fpdf": "1.8.*",
        "setasign/fpdi": "^2.0"

If you want to use TCPDF, you have to update your composer.json to:

    "require": {
        "tecnickcom/tcpdf": "6.3.*",
        "setasign/fpdi": "^2.0"

If you want to use tFPDF, you have to update your composer.json to:

    "require": {
        "setasign/tfpdf": "1.31.*",
        "setasign/fpdi": "^2.3"

Manual Installation

If you do not use composer, just require the autoload.php in the /src folder:


If you have a PSR-4 autoloader implemented, just register the src path as follows:

$loader = new \Example\Psr4AutoloaderClass;
$loader->addNamespace('setasign\Fpdi', 'path/to/src/');

Changes to Version 1

Version 2 is a complete rewrite from scratch of FPDI which comes with:

We tried to keep the main methods and logical workflow the same as in version 1 but please
notice that there were incompatible changes which you should consider when updating to
version 2:

Example and Documentation

A simple example, that imports a single page and places this onto a new created page:

use setasign\Fpdi\Fpdi;
// or for usage with TCPDF:
// use setasign\Fpdi\Tcpdf\Fpdi;

// or for usage with tFPDF:
// use setasign\Fpdi\Tfpdf\Fpdi;

// setup the autoload function

// initiate FPDI
$pdf = new Fpdi();
// add a page
// set the source file
// import page 1
$tplId = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplId, 10, 10, 100);


A full end-user documentation and API reference is available here.