Last active
January 29, 2016 14:29
-
-
Save mthomas88/3ee5435450a6fc15e474 to your computer and use it in GitHub Desktop.
Quick dirty script you can use in a job if you need to merge PDF's together.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace PDFMerge; | |
use Symfony\Component\Process\Process; | |
use Symfony\Component\Process\Exception\ProcessFailedException; | |
// new empty array to fill with appendix documents. | |
$doc_array = []; | |
// add to the document array for each appendix item. | |
foreach($documents as $doc) { | |
$doc_array[] = storage_path() . '/app/' . $doc->filepath; | |
} | |
// in case anyone else get's stuck :) | |
$filename = str_random(20); | |
$path = storage_path() . '/' . $filename | |
// depending on what workstation i'm working on, switch between the windows cmd | |
// or the unix cmd, either works. | |
$unix_cmd = 'gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile='.$path.' '.$implode; | |
$win_cmd = 'gswin64c -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile='.$path.' '.$implode; | |
// install ghostscript on the vps for this to work. :( | |
$process = new Process($unix_cmd); | |
$process->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment