PHPackages                             kalpvaig/laravel-pdf-merger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. kalpvaig/laravel-pdf-merger

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

kalpvaig/laravel-pdf-merger
===========================

Package for Laravel that merges multiple PDFs into one.

0103PHP

Since Aug 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/50shashwat/laravel-pdf-merger)[ Packagist](https://packagist.org/packages/kalpvaig/laravel-pdf-merger)[ RSS](/packages/kalpvaig-laravel-pdf-merger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel PDF Merger
==================

[](#laravel-pdf-merger)

PDF merger for Laravel inspired by another package, created for personal use. Tested with Laravel 5.6.

Advantages
----------

[](#advantages)

- Also works with PDF versions above `1.4`
- Works with `PHP 7`

Installation
------------

[](#installation)

```
 $ composer require kalpvaig/laravel-pdf-merger
```

Configuration
-------------

[](#configuration)

Make the following changes to the main configuration file located at `config/app.php`

```
'providers' => [
   ...
   Kalpvaig\LaravelPDFMerger\Providers\PDFMergerServiceProvider::class
],

'aliases' => [
   ...
   'PDFMerger' => Kalpvaig\LaravelPDFMerger\Facades\PDFMergerFacade::class
]
```

> When merging PDFs versions above 1.4 or PDF strings, a temporary PDF will be created during the process and stored in `storage/app/public/tmp` directory, therefore you may need to create it beforehand. Also, note that this package requires Ghostscript installed on the server in order to functiona properly with PDF versions 1.5+. [Install Guide](https://www.ghostscript.com/doc/9.20/Install.htm)

Required Packages for Ubuntu Server
-----------------------------------

[](#required-packages-for-ubuntu-server)

```
- `sudo apt install ghostscript`
// ghostscript should be installed on your machine

```

Usage
-----

[](#usage)

You can add PDFs for merging, by specifying a file path of PDF with `addPathToPDF` method, or adding PDF file as string with `addPDFString` method. The second argument of both methods is array of selected pages (`'all'` for all pages) and the third argument is PDFs orientation (portrait or landscape).

```
$merger->addPathToPDF('/path/to/pdf', 'all', 'P');
$merger->addPDFString(file_get_contents('path/to/pdf'), ['1', '2'], 'L')
```

You can set a merged PDF name by using `setFileName` method.

```
$merger->setFileName('merger.pdf');
```

In the end, finnish process with `merge` or `duplexMerge` method and use one of the output options for the merged PDF. The difference bwetween two methods is, that `duplexMerge` adds blank page after each merged PDF, if it has odd number of pages.

Available output options are:

- `inline()`
- `download()`
- `string()`
- `save('path/to/merged.pdf')`

```
$merger->merge();
$merger->inline();
```

Example usage
-------------

[](#example-usage)

```
$merger = new PDFMerger(new Filesystem());

$merger->addPathToPDF(base_path('/vendor/kalpvaig/laravel-pdf-merger/examples/one.pdf'), [2], 'P');
$merger->addPDFString(file_get_contents(base_path('/vendor/kalpvaig/laravel-pdf-merger/examples/two.pdf')), 'all', 'L');

// Or You can use A for detecting automatic orientation
$merger->addPDFString(file_get_contents(base_path('/vendor/kalpvaig/laravel-pdf-merger/examples/three.pdf')), 'all', 'A');

$merger->merge();
$merger->save(base_path('/public/pdfs/merged.pdf'));
```

Authors
-------

[](#authors)

- [GrofGraf](https://github.com/GrofGraf)
- \[Shashwat\] ()

Credits
-------

[](#credits)

- **Webklex** [LaravelPDFMerger](https://github.com/Webklex/laravel-pdfmerger)

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2017 Shashwat (Previous Maintainer - GrofGraf)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 55.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/86f7b73f241c9ff855381125e550e8235f4000042bdd5765e750637d8aa5c082?d=identicon)[50shashwat](/maintainers/50shashwat)

---

Top Contributors

[![GrofGraf](https://avatars.githubusercontent.com/u/16609463?v=4)](https://github.com/GrofGraf "GrofGraf (20 commits)")[![shashwat-kalpvaig](https://avatars.githubusercontent.com/u/7128146?v=4)](https://github.com/shashwat-kalpvaig "shashwat-kalpvaig (14 commits)")[![drfraker](https://avatars.githubusercontent.com/u/1279323?v=4)](https://github.com/drfraker "drfraker (1 commits)")[![synapsewebtechadmin](https://avatars.githubusercontent.com/u/7449947?v=4)](https://github.com/synapsewebtechadmin "synapsewebtechadmin (1 commits)")

### Embed Badge

![Health badge](/badges/kalpvaig-laravel-pdf-merger/health.svg)

```
[![Health](https://phpackages.com/badges/kalpvaig-laravel-pdf-merger/health.svg)](https://phpackages.com/packages/kalpvaig-laravel-pdf-merger)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.3k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M131](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
