karriere / pdf-merge
A wrapper for the TCPDF class that provides an elegant API for merging PDFs
Installs: 207 852
Dependents: 1
Suggesters: 0
Security: 0
Stars: 25
Watchers: 4
Forks: 9
Open Issues: 1
Requires
- php: 8.1.* | 8.2.* | 8.3.* | 8.4.*
- tecnickcom/tcpdf: ^6.3
Requires (Dev)
- laravel/pint: ^1.5 | ^1.6
- pestphp/pest: ^1.22
- phpstan/phpstan: ^1.10
This package is auto-updated.
Last update: 2024-12-05 08:00:45 UTC
README
Pdf Merge Solution for PHP
This package is a wrapper for the TCPDF
class that provides an elegant API for merging PDF files.
Installation
You can install the package via composer:
composer require karriere/pdf-merge
Usage
use Karriere\PdfMerge\PdfMerge; $pdfMerge = new PdfMerge(); $pdfMerge->add('/path/to/file1.pdf'); $pdfMerge->add('/path/to/file2.pdf'); $pdfMerge->merge('/path/to/output.pdf');
Please note, that the merge()
-method will throw a NoFilesDefinedException
if no files where added.
Check for file existence
You can check if a file was already added for merging by calling:
$pdfMerge->contains('/path/to/file.pdf');
Configuring header and footer
You can also configure the header of footer of all pages like this:
use Karriere\PdfMerge\PdfMerge; $pdfMerge = new PdfMerge( new HeaderConfig( imagePath: 'header_logo.png', logoWidthMM: 20, title: 'Header', text: 'This is a header text', textColor: new RGB(200, 200, 200), lineColor: new RGB(0, 0, 255), ), new FooterConfig( textColor: new RGB(100, 100, 100), lineColor: new RGB(255, 0, 0), margin: 20, ), );
All config properties have default values, so you don't have to pass them all.
License
Apache License 2.0 Please see LICENSE for more information.