setasign/fpdi
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The setasign/fpdi
is a collection of PHP classes which allows developers to read pages from existing PDF documents and use them as templates in their PHP applications. It works incredibly well with FPDF and can also be used with TCPDF and tFPDF. This package doesn't have pre-fixed dependencies, allowing you to decide the PDF generation library suitable for your project. FPDI is especially valuable for projects requiring PDF manipulations, such as importing pages from one PDF document and using them in another.
To use setasign/fpdi
, you first need to include it in your project. This can be done via composer. Depending on whether you use FPDF, TCPDF or tFPDF, you will need to modify the require
block in your composer.json
file accordingly. For example, to use FPDI with FPDF, your composer.json
file should look like this:
{
"require": {
"setasign/fpdf": "1.8.*",
"setasign/fpdi": "^2.0"
}
}
And for TCPDF or tFPDF, you mist replace setasign/fpdf
with tecnickcom/tcpdf
or setasign/fpdi
respectively. After running composer install
, you can use FPDI in your code. Here's an example of how to import a page from an existing PDF and use it in a new document:
use setasign\Fpdi\Fpdi;
// setup the autoload function
require_once('vendor/autoload.php');
// initiate FPDI
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("ExistingDocument.pdf");
// import page 1
$tplId = $pdf->importPage(1);
// use the imported page and place it at the coordinates 10,10 with a width of 100 mm
$pdf->useTemplate($tplId, 10, 10, 100);
$pdf->Output();
Complete documentation for setasign/fpdi
is available at the following URL: https://manuals.setasign.com/fpdi-manual/. The documentation provides in-depth insights and details about the FPDI package, helping you configure it to suit your project needs. For more details on getting started, using and integrating setasign/fpdi
into PHP applications, refer to this documentation.