Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Tomsgu/PDFMerger
Simple wrapper for merging pdf files for PHP >= 7.2.
https://github.com/Tomsgu/PDFMerger
Last synced: 3 months ago
JSON representation
Simple wrapper for merging pdf files for PHP >= 7.2.
- Host: GitHub
- URL: https://github.com/Tomsgu/PDFMerger
- Owner: Tomsgu
- License: mit
- Created: 2018-06-04T07:52:14.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-12-02T14:58:36.000Z (12 months ago)
- Last Synced: 2024-07-19T03:50:32.969Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 91.8 KB
- Stars: 15
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PDFMerger
Simple wrapper for merging pdfs for PHP >= 7.2 based on setasign/fpdi and fpdf libraries, inspired by clegginabox/pdf-merger.When using a symfony framework you can use [tomsgu/pdf-merger-bundle](https://github.com/Tomsgu/PDFMergerBundle) bundle.
# Installation
```bash
composer require tomsgu/pdf-merger
```# Usage
```php
$pdfCollection = new PdfCollection();
$pdfCollection->addPdf('filename.pdf', PdfFile::ALL_PAGES, PdfFile::ORIENTATION_PORTRAIT);
$pdfCollection->addPdf('filename2.pdf', '1-4,9', PdfFile::ORIENTATION_LANDSCAPE);
$pdfCollection->addPdf('filename3.pdf', '1-4,9', PdfFile::ORIENTATION_AUTO_DETECT);
$pdfCollection->addPdf('filename4.pdf');// You can also pass a resource
$resource = fopen('filename4.pdf', 'r');
$pdfCollection->addPdf($resource);$fpdi = new Fpdi();
$merger = new PdfMerger($fpdi);
/**
* Available modes: MODE_FILE, MODE_DOWNLOAD, MODE_STRING, MODE_BROWSER
* Orientation: This is a fallback if the orientation wasn't specified when adding pdf.
*/
$merger->merge($pdfCollection, 'output.pdf', PdfMerger::MODE_FILE, PdfFile::ORIENTATION_LANDSCAPE);
```