You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Julio Montoya
5f7d19f3e7
|
11 years ago | |
---|---|---|
.. | ||
src/Ghostscript | 11 years ago | |
tests | 11 years ago | |
.gitignore | 11 years ago | |
.travis.yml | 11 years ago | |
CHANGELOG.md | 11 years ago | |
LICENSE | 11 years ago | |
README.md | 11 years ago | |
composer.json | 11 years ago | |
composer.lock | 11 years ago | |
phpunit.xml.dist | 11 years ago |
README.md
Ghostscript PHP driver
API usage
To instantiate Ghostscript driver, the easiest way is :
$transcoder = Ghostscript\Transcoder::create();
You can customize your driver by passing a Psr\Log\LoggerInterface
or
configuration options.
Available options are :
gs.binaries
: the path (or an array of potential paths) to the ghostscript binary.timeout
: the timeout for the underlying process.
$transcoder = Ghostscript\Transcoder::create(array(
'timeout' => 42,
'gs.binaries' => '/opt/local/gs/bin/gs',
), $logger);
To process a file to PDF format, use the toPDF
method :
Third and fourth arguments are respectively the first page and the number of page to transcode.
$transcoder->toPDF('document.pdf', 'first-page.pdf', 1, 1);
To render a file to Image, use the toImage
method :
$transcoder->toImage('document.pdf', 'output.jpg');
Silex service provider :
A Silex Service Provider is available, all parameters are optionals :
$app = new Silex\Application();
$app->register(new Ghostscript\GhostscriptServiceProvider(), array(
'ghostscript.configuration' => array(
'gs.binaries' => '/usr/bin/gs',
'timeout' => 42,
)
'ghostscript.logger' => $app->share(function () {
return $app['monolog']; // use Monolog service provider
}),
));
$app['ghostscript.pdf-transcoder']->toImage('document.pdf', 'image.jpg');
License
Released under the MIT License