Using Laravel for a web app where I am using https://github.com/clegginabox/pdf-merger to merge pdf files and ran into the following error when trying to merge two pdfs together where one was over version 1.4:
Exception in pdf_parser.php line 133:
This document (C:\path-to-doc\file.pdf) probably uses a compression technique
which is not supported by the free parser shipped with FPDI.
(See https://www.setasign.com/fpdi-pdf-parser for more details)
in pdf_parser.php line 133
I followed the suggestion in the following answer to use ghostscript to convert any pdf over 1.4 to 1.4 so the merge will work.
I've installed ghostscript successfully and added it to my path. For testing I have a sample pdf file which is version 1.5 called test.pdf
and I run the following command from the windows terminal:
gswin64 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=new-file.pdf test-file.pdf
and I get my new-file.pdf
just fine as version 1.4.
Now I have the following php script which when ran from the web browser just loads continuously. If I let it run a bit sometimes a new file has been created but it's like 3kb in size and blank and also the original pdf file comes blank sometimes?!
<?php
shell_exec( "gswin64 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=new-file.pdf test-file.pdf");
echo 'done';
Any ideas what I'm doing wrong?