PHPackages                             virdiggg/merge-files - 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. virdiggg/merge-files

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

virdiggg/merge-files
====================

Merge words, excel, PDF and image into a single PDF

2.2.0(1y ago)174MITPHPPHP &gt;=7.3.0

Since Nov 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/virdiggg/merge-files)[ Packagist](https://packagist.org/packages/virdiggg/merge-files)[ RSS](/packages/virdiggg-merge-files/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (3)Versions (14)Used By (0)

Merge Files
===========

[](#merge-files)

A lightweight PHP document merging library designed for practical backend workflows and legacy PDF compatibility handling.

This library allows multiple document types—including Word, Excel, images, and existing PDFs—to be consolidated into a single PDF output through a unified processing pipeline.

Unlike many PDF merging utilities that fail on newer PDF structures, this library automatically normalizes incompatible PDF versions using Ghostscript preprocessing to maintain compatibility with legacy PHP PDF ecosystems such as FPDF, FPDI, and mPDF.

---

[![](https://camo.githubusercontent.com/384aaeac5ac31b49cf3b8a4bfe2811c720b390117319c63ee0f524c1e211de6a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f76697264696767672f6d657267652d66696c6573)](https://camo.githubusercontent.com/384aaeac5ac31b49cf3b8a4bfe2811c720b390117319c63ee0f524c1e211de6a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f76697264696767672f6d657267652d66696c6573)[![](https://camo.githubusercontent.com/18e4ddcfbbc33e726cef9f1c5fcaad1d1ec32ae903a2bd6ace8f3b6743190a08/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f646569676e697465722d2d76657273696f6e2d332d677265656e)](https://camo.githubusercontent.com/18e4ddcfbbc33e726cef9f1c5fcaad1d1ec32ae903a2bd6ace8f3b6743190a08/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f646569676e697465722d2d76657273696f6e2d332d677265656e)[![](https://camo.githubusercontent.com/9bb19b7df62dbed74d8dfc0eb58cc5cf257c0760bfb159a2a7b72d16aac5309b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f76697264696767672f6d657267652d66696c6573)](https://camo.githubusercontent.com/9bb19b7df62dbed74d8dfc0eb58cc5cf257c0760bfb159a2a7b72d16aac5309b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f76697264696767672f6d657267652d66696c6573)

---

Features
--------

[](#features)

- Merge multiple file formats into a single PDF
- Automatic PDF compatibility normalization using Ghostscript
- Handles mixed document ingestion workflows
- Supports PDF metadata configuration
- Optional PDF permission restrictions
- Lightweight and framework-friendly
- Designed for internal systems and document automation pipelines

---

Supported File Types
--------------------

[](#supported-file-types)

- DOC
- DOCX
- XLS
- XLSX
- JPG
- JPEG
- PNG
- PDF

---

Why Ghostscript Is Required
---------------------------

[](#why-ghostscript-is-required)

Many PHP PDF libraries such as FPDI, FPDF, and mPDF have limitations when importing or merging PDFs generated with newer PDF specifications (commonly PDF 1.5+).

This library automatically preprocesses incompatible PDFs through Ghostscript to:

- Normalize PDF versions
- Improve merge compatibility
- Prevent parser/import failures
- Avoid dependency on commercial PDF parser addons

Ghostscript is therefore a mandatory dependency.

---

Current Limitations
-------------------

[](#current-limitations)

### Embedded Images Inside DOC/DOCX

[](#embedded-images-inside-docdocx)

Images embedded inside `.doc` or `.docx` files are currently not supported during conversion.

### Maintenance Status

[](#maintenance-status)

This project is currently in maintenance mode.
No major feature updates are planned at the moment.

### Required PHP Extension

[](#required-php-extension)

The `mbstring` extension is required.

---

Installation
============

[](#installation)

Install the package via Composer:

```
composer require virdiggg/merge-files
```

---

Ghostscript Installation
========================

[](#ghostscript-installation)

Install Ghostscript and ensure the `gs` command is globally accessible from your terminal or command prompt.

Official installation guide:

Verify installation:

```
gs
```

Expected output:

```
GPL Ghostscript 10.xx.x
GS>
```

---

Basic Usage
===========

[](#basic-usage)

```
