Skip to content

Instantly share code, notes, and snippets.

@kyletaylored
Created September 11, 2021 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyletaylored/154bd56c73cb0f76db95527dcbe1eb15 to your computer and use it in GitHub Desktop.
Save kyletaylored/154bd56c73cb0f76db95527dcbe1eb15 to your computer and use it in GitHub Desktop.
Using custom bin / exe on Pantheon
<?php
// Ghostscript example
// https://www.ghostscript.com/download/gsdnld.html
// Disable cache
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
echo "<pre>";
// Create PDF paths
$files = implode(" ", array_map(function($file) {
return "'{$file}'";
}, ['sample.pdf', 'sample2.pdf']));
// Make temp file path
$time = time();
$temp_file = "../sites/default/files/{$time}-sample-gs.pdf";
// Run Ghostscript
passthru("gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile='$temp_file' {$files}");
echo "</pre>";
<?php
// xPDF
// https://www.xpdfreader.com/download.html
// Disable cache
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
$bin = $_ENV['DOCROOT'] . 'bin';
echo "<pre>";
passthru("{$bin}/pdfinfo sample.pdf");
echo "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment