PHP wrapper class for Ghostscript API
- PHP >= 7.4.0
- Ghostscript >= 9.18
- ext-ffi (Foreign Function Interface extension)
php composer.phar require "fawno/gsapi"
<?php
require __DIR__ . '/vendor/autoload.php';
use Fawno\GhostscriptAPI\GSAPI;
require __DIR__ . '/vendor/autoload.php';
use Fawno\GhostscriptAPI\GSAPI;
use Fawno\GhostscriptAPI\GSAPIException;
$gs = new GSAPI('/usr/gs920/bin/gsdll64.dll');
$params = [
'-sDEVICE=pdfwrite',
'-dPDFSETTINGS=/ebook',
'-sOutputFile=ebook.pdf',
'original.pdf',
];
try {
$gs->run_with_args($params);
} catch (GSAPIException $exception) {
echo $exception;
}