PHPackages                             ttbooking/phpgs - 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. ttbooking/phpgs

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

ttbooking/phpgs
===============

PHP Wrapper for Ghost Script

2.0.2(2y ago)087MITPHPPHP ^8.0

Since Nov 1Pushed 2y agoCompare

[ Source](https://github.com/ttbooking/phpgs)[ Packagist](https://packagist.org/packages/ttbooking/phpgs)[ RSS](/packages/ttbooking-phpgs/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

PHPgs
=====

[](#phpgs)

This package provides PHP Wrapper for **GhostScript**. It also provides a simple tool for **PDF** pages splitting / merging.

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

[](#installation)

```
composer require ttbooking/phpgs
```

Usage
-----

[](#usage)

### Executor

[](#executor)

For general purpose use ***Executor*** as a generic wrapper for the Ghost Script

```
use Webit\PHPgs\ExecutorBuilder;
use Webit\PHPgs\Input;
use Webit\PHPgs\Output;
use Webit\PHPgs\Options\Options;
use Webit\PHPgs\Options\Device;

/** @var \Webit\PHPgs\Executor $executor */
$executor = ExecutorBuilder::create()->setGhostScriptBinary('/path/to/the/binary/of/gs')->build();

$input = Input::singleFile('/path/to/your/input_file');
$output = Output::create('/path/to/your/tempdir/output.pdf');

// Please note Options class is immutable (every change creates a new instance)
$options = Options::create(Device::pdfWrite())
            // set predefined options (see Options class for all predefined options)
            ->withNoTransparency()
            ->useCropBox()
            ->useCIEColor()
            // change any option you need
            ->withOption('-dWhatever', 'value of whatever');

$executor->execute($input, $output, $options);
```

### PdfManipulator

[](#pdfmanipulator)

***PdfManipulator*** provides simplified interface for PDF splitting / merging

#### Merging

[](#merging)

```
use Webit\PHPgs\Pdf\PdfManipulator;

$pdfManipulator = new PdfManipulator($executor);

$input = Input::multipleFiles(
    array(
        'one.pdf',
        'two.pdf',
        'three.pdf'
    )
);

$output = Output::create('/temp-dir/random-5322/output.pdf');

$customOptions = Options::create(); // optional

$pdfManipulator->merge($input, $output, $customOptions);
```

#### Splitting pages

[](#splitting-pages)

```
use Webit\PHPgs\Pdf\PdfManipulator;

$pdfManipulator = new PdfManipulator($executor);

$input = Input::singleFile('multipage.pdf');

// multi page output
$output = Output::create('/temp-dir/random-12322/output-%d.pdf');

// single page output
// $output = Output::create('/temp-dir/random-12322/output.pdf');

$customOptions = Options::create(); // optional

// splitting pages from 5 to 10
$pdfManipulator->split($input, $output, 5, 10, $customOptions);
// produces output-5.pdf, output-6.pdf, ...

// splitting pages from 5 to the last page
$pdfManipulator->split($input, $output, 5, null, $customOptions);
// produces output-5.pdf, output-6.pdf, ...

// splitting pages from 1 to 10
$pdfManipulator->split($input, $output, null, 10, $customOptions);
// produces output-1.pdf, output-2.pdf, ..., output-10.pdf
```

**Note:** To make sure multi-page splitting will work properly, an output ***always*** must refer to an ***empty***directory.

Tests
-----

[](#tests)

```
docker-compose run --rm php5 ./vendor/bin/phpunit
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~774 days

Total

4

Last Release

796d ago

Major Versions

1.0.0 → 2.0.02022-05-12

PHP version history (2 changes)1.0.0PHP &gt;=5.3.9

2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fa409df9a204429e6f7bb8a0f2baf6516891c903be4d176b463bc79453a1b555?d=identicon)[EgorGruzdev](/maintainers/EgorGruzdev)

---

Top Contributors

[![daniser](https://avatars.githubusercontent.com/u/5169543?v=4)](https://github.com/daniser "daniser (1 commits)")

---

Tags

ghostscriptpdf mergeghost scriptgspdf split

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ttbooking-phpgs/health.svg)

```
[![Health](https://phpackages.com/badges/ttbooking-phpgs/health.svg)](https://phpackages.com/packages/ttbooking-phpgs)
```

###  Alternatives

[mostafaznv/pdf-optimizer

PDF optimization tool for PHP and Laravel applications

170125.8k](/packages/mostafaznv-pdf-optimizer)[imal-h/pdf-box

The most advanced, driver-based PDF manipulation library for PHP v3.0. Supports Ghostscript, Chrome Headless (HTML to PDF), OpenSSL/FPDI (Signing), and PDFtk (Forms).

60403.9k](/packages/imal-h-pdf-box)[ismaelw/laratex

A package for creating PDFs in Laravel using LaTeX

12730.1k](/packages/ismaelw-laratex)[alchemy/ghostscript

Ghostscript PDF, a library to handle PDF through ghostscript

30316.5k3](/packages/alchemy-ghostscript)[tomsgu/pdf-merger

21473.9k23](/packages/tomsgu-pdf-merger)[rockett/weasyprint

A feature-rich Laravel wrapper for the WeasyPrint Document Factory.

28199.7k](/packages/rockett-weasyprint)

PHPackages © 2026

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