1. Go to this page and download the library: Download gravitymedia/ghostscript library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gravitymedia / ghostscript example snippets
// Initialize autoloader
ravityMedia\Ghostscript\Ghostscript;
use Symfony\Component\Process\Process;
// Define input and output files
$inputFile = '/path/to/input/file.pdf';
$outputFile = '/path/to/output/file.pdf';
// Create Ghostscript object
$ghostscript = new Ghostscript([
'quiet' => false
]);
// Create and configure the device
$device = $ghostscript->createPdfDevice($outputFile);
$device->setCompatibilityLevel(1.4);
// Create process
$process = $device->createProcess($inputFile);
// Print the command line
print '$ ' . $process->getCommandLine() . PHP_EOL;
// Run process
$process->run(function ($type, $buffer) {
if ($type === Process::ERR) {
throw new \RuntimeException($buffer);
}
print $buffer;
});
bash
$ php composer.phar
bash
$ php composer.phar install
bash
$ php composer.phar test
bash
$ php composer.phar install
bash
$ php composer.phar doc
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.