Download the PHP package ngekoding/pdf-merger without Composer
On this page you can find all versions of the php package ngekoding/pdf-merger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ngekoding/pdf-merger
More information about ngekoding/pdf-merger
Files in ngekoding/pdf-merger
Package pdf-merger
Short Description Merge multiple PDF files into a single PDF using Ghostscript.
License MIT
Informations about the package pdf-merger
pdf-merger
Merge multiple PDF files into a single PDF using Ghostscript.
This library uses the Ghostscript CLI to efficiently merge PDF files on Linux or any environment where Ghostscript is installed.
Why this library?
There are many PDF merger libraries out there, but most rely on FPDI, which has limitations in its free version—especially when dealing with certain types of PDFs.
We created pdf-merger as a simple alternative that uses Ghostscript instead, offering a reliable and unrestricted solution for merging PDFs without those limitations.
Requirements
- PHP 5.6 or above
- Ghostscript CLI (
gs
command)
Installation
Usage
Simple usage
Adding files one by one
Setting custom output folder and filename
By default, the merged PDF will be saved in your system's temp directory with a timestamped filename.
You can customize the output folder and/or filename:
Setting output file directly
Instead of setting output folder and filename separately, you can set the full output file path directly:
Setting Ghostscript executable path
If gs
is not in your system PATH or you want to use a custom Ghostscript binary:
Setting compression level
You can choose one of the predefined Ghostscript compression levels using the setCompressionLevel()
method. The library provides constants for convenience:
Note:
Using CompressionLevel::NONE
will skip the -dPDFSETTINGS
parameter entirely, resulting in output that is as close as possible to the original quality.
For more technical details, you can refer to the Ghostscript documentation.
Setting process timeout
By default, the Ghostscript process timeout is 60 seconds.
You can change it (in seconds) or disable by passing null
:
Resetting the merger instance
You can reset the internal state (input files, output settings, compression, etc.) to start fresh:
Notes
- At least two PDF files are required for merging.
- The library throws exceptions on errors — use try-catch blocks for error handling in production.
License
This project is open-sourced under the MIT license.