https://github.com/karriereat/pdf-merge
This package is a wrapper for the TCPDF class that provides an elegant API for merging PDF files.
https://github.com/karriereat/pdf-merge
fpdf-library pdf php wrapper
Last synced: 9 months ago
JSON representation
This package is a wrapper for the TCPDF class that provides an elegant API for merging PDF files.
- Host: GitHub
- URL: https://github.com/karriereat/pdf-merge
- Owner: karriereat
- License: other
- Created: 2020-03-24T14:30:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-19T11:03:09.000Z (over 1 year ago)
- Last Synced: 2025-09-17T21:49:19.394Z (9 months ago)
- Topics: fpdf-library, pdf, php, wrapper
- Language: PHP
- Homepage: https://packagist.org/packages/karriere/pdf-merge
- Size: 160 KB
- Stars: 27
- Watchers: 3
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://packagist.org/packages/karriere/pdf-merge)
# 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:
```bash
composer require karriere/pdf-merge
```
## Usage
```php
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:
```php
$pdfMerge->contains('/path/to/file.pdf');
```
### Configuring header and footer
You can also configure the header of footer of all pages like this:
```php
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](LICENSE) for more information.