123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. FPDI - Free PDF Document Importer
  2. =================================
  3. [![Latest Stable Version](https://poser.pugx.org/setasign/fpdi/v/stable.svg)](https://packagist.org/packages/setasign/fpdi) [![Total Downloads](https://poser.pugx.org/setasign/fpdi/downloads.svg)](https://packagist.org/packages/setasign/fpdi) [![Latest Unstable Version](https://poser.pugx.org/setasign/fpdi/v/unstable.svg)](https://packagist.org/packages/setasign/fpdi) [![License](https://poser.pugx.org/setasign/fpdi/license.svg)](https://packagist.org/packages/setasign/fpdi)
  4. A clone of [FPDI](https://www.setasign.com/fpdi) for GitHub/[Composer](https://packagist.org/packages/setasign/fpdi).
  5. 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.
  6. ## Installation with [Composer](https://packagist.org/packages/setasign/fpdi)
  7. FPDI is an add-on for [FPDF](http://fpdf.org/). Additionally FPDI can be used with [TCPDF](http://www.tcpdf.org/).
  8. For completion we added a [FPDF repository](https://github.com/Setasign/FPDF) which simply clones the offical releases.
  9. This package comes without any dependency configuration in the composer.json file. It's up to you to load the desired package as described below.
  10. A basic installation via Composer could be done this way:
  11. ```bash
  12. $ composer require setasign/fpdi:1.6.1
  13. ```
  14. or you can include the following in your composer.json file:
  15. ```json
  16. {
  17. "require": {
  18. "setasign/fpdi": "1.6.1"
  19. }
  20. }
  21. ```
  22. ### Evaluate Dependencies Automatically
  23. To load dependencies automatically we prepared kind of metadata packages. To use FPDI with FPDF use [this](https://github.com/Setasign/FPDI-FPDF) package:
  24. ```json
  25. {
  26. "require": {
  27. "setasign/fpdi-fpdf": "1.6.1"
  28. }
  29. }
  30. ```
  31. For TCPDF use [this](https://github.com/Setasign/FPDI-TCPDF):
  32. ```json
  33. {
  34. "require": {
  35. "setasign/fpdi-tcpdf": "1.6.1"
  36. }
  37. }
  38. ```
  39. ### Manual Dependencies
  40. To support both FPDF and TCPDF its up to you to load the preferred package before the classes of FPDI are loaded. By default FPDI will extend FPDF. If the TCPDF class exists, a new FPDF class will be created which will extend TCPDF while FPDI will extend this.
  41. To use FPDI with FPDF include following in your composer.json file:
  42. ```json
  43. {
  44. "require": {
  45. "setasign/fpdf": "1.8",
  46. "setasign/fpdi": "1.6.1"
  47. }
  48. }
  49. ```
  50. If you are using TCPDF, your have to update your composer.json respectively to:
  51. ```json
  52. {
  53. "require": {
  54. "tecnickcom/tcpdf": "6.2.12",
  55. "setasign/fpdi": "1.6.1"
  56. }
  57. }
  58. ```
  59. Additionally you have to trigger composers autoloader for the TCPDF class before you are initiating FPDI:
  60. ```php
  61. class_exists('TCPDF', true); // trigger Composers autoloader to load the TCPDF class
  62. $pdf = new FPDI();
  63. ```