-
Notifications
You must be signed in to change notification settings - Fork 38
ghostscript
Imal Perera edited this page Jan 2, 2026
·
1 revision
The GhostscriptDriver is the workhorse of PDFLib. It handles almost all manipulation tasks.
use ImalH\PDFLib\PDF;
// Initialize
$pdf = PDF::init()->driver(PDF::DRIVER_GHOSTSCRIPT);Convert a PDF page (default: Page 1) to an image.
$pdf->from('doc.pdf')
->to('output.jpg')
->convert();Combine multiple PDF files into one.
$pdf->merge([
'cover.pdf',
'content.pdf',
'appendix.pdf'
], 'full_report.pdf');Add User/Owner passwords and restrict permissions.
$pdf->from('sensitive.pdf')
->encrypt('userPass123', 'ownerRules!', 'locked.pdf');Optimize file size using Ghostscript's presets (screen, ebook, printer, prepress, default).
$pdf->compress('heavy.pdf', 'light.pdf', 'ebook');-
rotate(int $degrees, string $dest): Rotate pages. -
watermark(string $text, string $dest): Add text watermark. -
split($range, string $dest): Extract pages (e.g.,'1-5'). -
getFormFields/fillForm: Not Supported (UsePdftkDriver).