yaroslavpopovic/laravel-pdf-merger

Laravel PDF Merger based on TCPDF — fork of softplaceweb/laravel-10-pdf-merger with Laravel 11/12/13 support.

Maintainers

Package info

github.com/yaroslavpopovic/laravel-pdf-merger

pkg:composer/yaroslavpopovic/laravel-pdf-merger

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

v2.0.0 2026-05-10 07:02 UTC

This package is auto-updated.

Last update: 2026-05-10 07:08:07 UTC


README

Latest Stable Version Total Downloads License

Fork of softplaceweb/laravel-10-pdf-merger with support for Laravel 11, 12 and 13.

A simple Laravel service provider with some basic configuration for including the TCPDF library to allow you to merge PDF's in your Laravel application.

Compatibility from 1.3 to 1.7 versions, if attempt to merge version greater than 1.4 it convert through Ghostscript.

The final result is a merged pdf file v 1.7

Requirements

  • PHP 8.2+
  • Laravel 11, 12 or 13
  • Ghostscript (gs command on Linux)

Installation

composer require yaroslavpopovic/laravel-pdf-merger

for lumen, you should add the following lines:

$app->register(Softplaceweb\PdfMerger\PdfMergerServiceProvider::class);
class_alias(Softplaceweb\PdfMerger\Facades\TCPDF::class, 'PDF');

That's it! You're good to go.

Here is a little example:

use Softplaceweb\PdfMerger\Facades\PdfMerger;

PdfMerger::addPDF('path/to/pdf1.pdf', 1)
->addPDF('path/to/pdf2.pdf', 'all')
->merge()
->save('new_file_name.pdf', 'browser');

or sending pdf's as array ...

use Softplaceweb\PdfMerger\Facades\PdfMerger;

PdfMerger::addPDF([
    [
        'filePath' => 'path/to/pdf1.pdf',
        'pages'    => 1,
    ],
    [
        'filePath' => 'path/to/pdf2.pdf',
    ],
])
->merge()
->save('new_file_name.pdf', 'browser');

You can extend functionality for this class and for a list of all available function take a look at the TCPDF Documentation

Configuration

Laravel Pdf Merger comes with some basic configuration. If you want to override the defaults, you can publish the config, like so:

php artisan vendor:publish --provider="Softplaceweb\PdfMerger\PdfMergerServiceProvider"

Now access config/pdf-merger.php to customize.

  • use_original_header is to used the original Header() from TCPDF.
    • Please note that PdfMerger::setHeaderCallback(function($pdf){}) overrides this settings.
  • use_original_footer is to used the original Footer() from TCPDF.
    • Please note that PdfMerger::setFooterCallback(function($pdf){}) overrides this settings.

Credits