PHPackages                             webit/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. [File &amp; Storage](/categories/file-storage)
4. /
5. webit/phpgs

ActiveLibrary[File &amp; Storage](/categories/file-storage)

webit/phpgs
===========

PHP Wrapper for Ghost Script

1.0.0(8y ago)12.7k4MITPHPPHP &gt;=5.3.9

Since Nov 1Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dbojdo/phpgs)[ Packagist](https://packagist.org/packages/webit/phpgs)[ RSS](/packages/webit-phpgs/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (2)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 webit/phpgs=^1.0
```

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

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3117d ago

### Community

Maintainers

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

---

Tags

ghostscriptpdf mergeghost scriptgspdf split

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/file-system-watcher

Watch changes in the file system using PHP

2502.1M17](/packages/spatie-file-system-watcher)

PHPackages © 2026

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