Installation System requirements and installation of FPDI
Table of Contents
System Requirements
FPDI 2 will run on any PHP version above 5.6.
An up to date PHP version (> 7) is recommend for best performance and memory results.
Following PHP extension must be enabled in the PHP configuration:
Because PDF parsing and writing is a performance intensive task the components should be used on a machine with a fast CPU. Also the max_execution_time value should be taken into account.
Same for memory usage. Because PDF documents are sometimes built with several thousands of individual objects, the components will need memory for managing these things. Maybe it is needed to touch the memory_limit value as well.
For sure FPDI requires an installation of FPDF, TCPDF or tFPDF, too. The documentation applies to the latest versions of all involved classes.
Installation
To install FPDI manually you have to download the package from the project website first.
Just extract the content of this package to a folder of your choice and add the /src folder to your PSR-4 autoload implementation:
$loader = new \Example\Psr4AutoloaderClass; $loader->register(); $loader->addNamespace('setasign\Fpdi', 'path/to/src/');
If you do not have a PSR-4 autoloader class in use, just require the autoload file manually:
require_once('path/to/src/autoload.php');
Don't forget to install FPDF, TCPDF or tFPDF before!
Via Composer
FPDI can be installed officially via Composer. The package can be found here.
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 yourself.
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.2.*", "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" } }
Usage with TCPDF
While the usage with TCPDF was done by a dynamic class in the past, it is required to use the class \setasign\Fpdi\Tcpdf\Fpdi
when using FPDI with TCPDF as of version 2.1 (in 2.0 it was \setasign\Fpdi\TcpdfFpdi
which is still available but marked as deprecated):
<?php use setasign\Fpdi\Tcpdf\Fpdi; $tcpdf = new Fpdi();
Usage with tFPDF
Since version 2.1 it is also possible to use FPDI with tFPDF. The classes are located in the namespace \setasign\Fpdi\Tfpdf
:
<?php use setasign\Fpdi\Tfpdf; $fpdi = new Tfpdf\Fpdi(); $fpdftpl = new Tfpdf\FpdfTpl();
Version Information
We use semantic versioning for FPDI as of version 2.
Version numbers are represented by three integer values:
[MAJOR].[MINOR].[PATCH]
- MAJOR
- The major version when we make incompatible API changes.
- MINOR
- The minor version when we add functionality in a backwards-compatible manner.
- PATCH
- The patch version when we make backwards-compatible bug fixes.
The version can be accessed by a class constants:
$fpdiVersion = \setasign\Fpdi\Fpdi::VERSION; // or $fpdiVersion = \setasign\Fpdi\TcpdfFpdi::VERSION;