Skip to content

Instantly share code, notes, and snippets.

@ilkermutlu
Last active April 9, 2024 11:23
Show Gist options
  • Save ilkermutlu/c38a72ecb60a1a9d65983b2528d5e69e to your computer and use it in GitHub Desktop.
Save ilkermutlu/c38a72ecb60a1a9d65983b2528d5e69e to your computer and use it in GitHub Desktop.
Convert PDF file to v1.4
// Not much of PHP magic
// This just takes a PDF file from a path
// and executes Ghostscript to convert your
// PDF to version 1.4

// You need to have Ghostscript installed
// See https://www.ghostscript.com/Documentation.html

$PDFFile = '/path/to/your/pdf.pdf';
$newName = substr($PDFFile, 0, -4) . '_new.pdf';
$command = 'gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=' . $newName . ' ' . $PDFFile;
exec($command);
@giuliopons
Copy link

Thank you. Fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment