Merging PDF Files
Merging PDF Files
I am trying to merge PDF files with imagemagick by means of convert. This works fine when I run the command direct from SSH, but when I run the exact same command from PHP, it doesn't work. Another thing is that the exec("convert string", $returnvar); $returnvar never returns anything even if it doesn't / does work. I know that imagemagick is installed and working with PHP, cause I can convert TIF's to PDF's and even merge multiple tifs to pdfs. I just cant merge multiple pdfs into one.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
This is a BAD idea.
See IM Examples... A word about Vector Image formats
http://www.cit.gu.edu.au/~anthony/graph ... ts/#vector
See IM Examples... A word about Vector Image formats
http://www.cit.gu.edu.au/~anthony/graph ... ts/#vector
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
tome100 wrote: Regaurdless, I still need to merge the PDF files.
You need somthing that works directly on vector files, since Imagmagick rasterizes PDFs before working with them.
A quick google reveals tools such as http://www.accesspdf.com/pdftk/. You might want to try that route.
Another route would be to merge the seperate tif files into one multipage tif, then saving as PDF.
Having done a lot of PDF merges in recent time (1,500,000 single page pdf files into 17,800 combined files) I found that the about PDFTK was the best. Unlike ImageMagick when you combine PDF files it does not rerender the images (which leads to image quality loss).
I do you ImageMagick and Ghostscript for every other PDF and image file processing.
I do you ImageMagick and Ghostscript for every other PDF and image file processing.
I never thought to use imagemagick for this.
I use Ghostscript directly to merge postscript and PDF files.
The command line I typically use (on a linux box) is of the form:
You can mix and match postscript and pdf files for the inputs.
Paul
I use Ghostscript directly to merge postscript and PDF files.
The command line I typically use (on a linux box) is of the form:
Code: Select all
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=Merged.pdf -dBATCH 1.ps 2.pdf 3.pdf
Paul
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
You could also try to set the 'PATH' environment yourself in the PHP. Though this is better done by the sys-admins in the the web server start up script.
This is also the best way for doing IM commandline calls from PHP.
However many Sys-admins will not do this as they don't know enough about web apps, and may consider such a request a security hole. Note that it is, as it is, as the apps can make the calls anyway! It just locks the web apps to specific machine setups. Arrrgghhh...
This is also the best way for doing IM commandline calls from PHP.
However many Sys-admins will not do this as they don't know enough about web apps, and may consider such a request a security hole. Note that it is, as it is, as the apps can make the calls anyway! It just locks the web apps to specific machine setups. Arrrgghhh...
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
I had some what of same issue.
my problem was that server has more then one version of imagemagick installed..
so when doing convert from ssh vs command line (Web) it calling up two differnt version.
to narrow down the issue i did was exec('convert -version') on the web to track down that SSH version is newest vs teh exec that ran a older version.
so if you analize the output of the exec version and compare it to ssh version #?
so i had to use a full path when calling it from exec() function..
solution for example..
exec('convert')
vs.
exec('/usr/bin/convert')
my problem was that server has more then one version of imagemagick installed..
so when doing convert from ssh vs command line (Web) it calling up two differnt version.
to narrow down the issue i did was exec('convert -version') on the web to track down that SSH version is newest vs teh exec that ran a older version.
so if you analize the output of the exec version and compare it to ssh version #?
so i had to use a full path when calling it from exec() function..
solution for example..
exec('convert')
vs.
exec('/usr/bin/convert')