All Projects → Setasign → Fpdi

Setasign / Fpdi

Licence: mit
FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF.

Labels

Projects that are alternatives of or similar to Fpdi

React Pdf Js
A React component to wrap PDF.js
Stars: ✭ 489 (-19.31%)
Mutual labels:  pdf
Changedetection
Automatically track websites changes on Android in background.
Stars: ✭ 563 (-7.1%)
Mutual labels:  pdf
Pdfarranger
Small python-gtk application, which helps the user to merge or split pdf documents and rotate, crop and rearrange their pages using an interactive and intuitive graphical interface
Stars: ✭ 583 (-3.8%)
Mutual labels:  pdf
Dart pdf
Pdf creation module for dart/flutter
Stars: ✭ 500 (-17.49%)
Mutual labels:  pdf
Combine pdf
A Pure ruby library to merge PDF files, number pages and maybe more...
Stars: ✭ 552 (-8.91%)
Mutual labels:  pdf
Koodo Reader
A modern ebook manager and reader with sync and backup capacities for Windows, macOS, Linux and Web
Stars: ✭ 2,938 (+384.82%)
Mutual labels:  pdf
Laravel Dompdf
A DOMPDF Wrapper for Laravel
Stars: ✭ 4,978 (+721.45%)
Mutual labels:  pdf
Images To Pdf
An app to convert images to PDF file!
Stars: ✭ 602 (-0.66%)
Mutual labels:  pdf
Pocorgtfo
a "Proof of Concept or GTFO" mirror with extra article index, direct links and clean PDFs.
Stars: ✭ 560 (-7.59%)
Mutual labels:  pdf
Vscode Markdown Pdf
Markdown converter for Visual Studio Code
Stars: ✭ 571 (-5.78%)
Mutual labels:  pdf
Mdpdf
Markdown to PDF command line app with support for stylesheets
Stars: ✭ 512 (-15.51%)
Mutual labels:  pdf
Jasperreports
JasperReports® - Free Java Reporting Library
Stars: ✭ 540 (-10.89%)
Mutual labels:  pdf
Tabula
Tabula is a tool for liberating data tables trapped inside PDF files
Stars: ✭ 5,420 (+794.39%)
Mutual labels:  pdf
Geeksforgeeks.pdf
Topic wise PDFs of Geeks for Geeks articles. (Last updated in October 2018)
Stars: ✭ 489 (-19.31%)
Mutual labels:  pdf
Libvips
A fast image processing library with low memory needs.
Stars: ✭ 6,094 (+905.61%)
Mutual labels:  pdf
Resume
👾 My resume / 我的简历
Stars: ✭ 482 (-20.46%)
Mutual labels:  pdf
Pikepdf
A Python library for reading and writing PDF, powered by qpdf
Stars: ✭ 566 (-6.6%)
Mutual labels:  pdf
Invoice Boilerplate
Simple automated LaTeX invoicing system
Stars: ✭ 604 (-0.33%)
Mutual labels:  pdf
Posterdown
Use RMarkdown to generate PDF Conference Posters via HTML
Stars: ✭ 602 (-0.66%)
Mutual labels:  pdf
Clj Pdf
PDF generation library for Clojure
Stars: ✭ 571 (-5.78%)
Mutual labels:  pdf

FPDI - Free PDF Document Importer

Latest Stable Version Total Downloads Latest Unstable Version License

❗️ This document refers to FPDI 2. Version 1 is deprecated and development is discontinued. ❗️

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 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.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:

require_once('src/autoload.php');

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

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

Changes to Version 1

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

  • Namespaced code
  • Clean and up-to-date code base and style
  • PSR-4 compatible autoloading
  • Performance improvements by up to 100%
  • Less memory consumption
  • Native support for reading PDFs from strings or stream-resources
  • Support for documents with "invalid" data before their file-header
  • Optimized page tree resolving
  • Usage of individual exceptions
  • Several test types (unit, functional and visual tests)

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:

  • You need to load the code using the src/autoload.php file instead of classes/FPDI.php.
  • The classes and traits are namespaced now: setasign\Fpdi
  • Page boundaries beginning with a slash, such as /MediaBox, are not supported anymore. Remove the slash or use a constant of PdfReader\PageBoundaries.
  • The parameters $x, $y, $width and $height of the useTemplate() or getTemplateSize() method have more logical correct default values now. Passing 0 as width or height will result in an InvalidArgumentException now.
  • The return value of getTemplateSize() had changed to an array with more speaking keys and reusability: Use width instead of w and height instead of h.
  • If you want to use FPDI with TCPDF you need to refactor your code to use the class Tcpdf\Fpdi (since 2.1; before it was TcpdfFpdi) instead of FPDI.

Example and Documentation

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

<?php
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
require_once('vendor/autoload.php');

// initiate FPDI
$pdf = new Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("Fantastic-Speaker.pdf");
// 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);

$pdf->Output();            

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].