jmleroux / pdf-merger
PDF File Merger for PHP 7
Installs: 66 435
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.2
- setasign/fpdf: ^1.8
- setasign/fpdi: ^2.3
- setasign/tfpdf: ^1.31
- tecnickcom/tcpdf: ^6.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpunit/phpunit: ^8.5|^9.1
This package is auto-updated.
Last update: 2024-11-06 20:09:53 UTC
README
Original written by http://pdfmerger.codeplex.com/team/view
Forked from https://github.com/clegginabox/pdf-merger
Installation
composer require jmleroux/pdf-merger
Example Usage
<?php use Jmleroux\PDFMerger\PDFMerger; $pdf = new PDFMerger(); $pdf->addPDF('samplepdfs/one.pdf', '1, 3, 4'); $pdf->addPDF('samplepdfs/two.pdf', '1-2'); $pdf->addPDF('samplepdfs/three.pdf', 'all'); //You can optionally specify a different orientation for each PDF $pdf->addPDF('samplepdfs/one.pdf', '1, 3, 4', 'L'); $pdf->addPDF('samplepdfs/two.pdf', '1-2', 'P'); $pdf->merge('file', 'samplepdfs/TEST2.pdf', 'P');
PDF libraries
You can use either FPDF, TCPDF or tFPDF as the internal PDF library by providing the right parameter to the constructor:
<?php use Jmleroux\PDFMerger\PDFMerger; $pdf = new PDFMerger(); // use FPDF $pdf = new PDFMerger('fpdf'); // use FPDF $pdf = new PDFMerger('tcpdf'); // use TCPDF $pdf = new PDFMerger('tfpdf'); // use tFPDF
Output modes
This merger uses verbose parameter names for the various pdf output modes common to the three libraries:
browser
(default): send the pdf binary to the browser. The borwser PDF plug-in is used if available.download
: send the pdf to the browser and force a file download with the name given.string
: outputs the raw binary string.file
: save to a local server file with the name given.
Development
This repo is shipped with a docker-compose file so that you don't need a local version of PHP.
Use make commands to install and run tests:
To install dependencies:
make vendor
To run tests:
make tests
WTF?
Yes, why the fork?
I first made a PR to fix the "slice feature", but I figured out I wanted a library with tests and tags. Plus, I wanted to add docker-compose because I do not have any local PHP installed anymore, so I decided to fork it and start with PHP 7.