0

This my gs command than merges 2 one-page pdf file:

gs -dNOPAUSE -dSAFER -sDEVICE=pdfwrite -sOUTPUTFILE=/tmp/blahblahblah.pdf -dBATCH page1.pdf page2.pdf

And this is the output:

GPL Ghostscript 8.70 (2009-07-31)
Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Processing pages 1 through 1.
Page 1
Can't find (or can't open) font file /usr/share/ghostscript/8.70/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Can't find (or can't open) font file /usr/share/ghostscript/8.70/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Querying operating system for font files...
Can't find (or can't open) font file /usr/share/ghostscript/8.70/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Didn't find this font on the system!
Substituting font Helvetica for ArialMT.
Loading NimbusSanL-Regu font from /usr/share/fonts/default/Type1/n019003l.pfb... 3397696 1943901 17192756 15861178 3 done.

The font ArialMT is not found and Helvetica is substituted with it. I got the merged file from server by scp and opened it in my local system. The file is properly merged including 2 pages. So file has no problem. Now I use the below command in order to get the PDF page count:

identify -format %n '/tmp/blahblahblah.pdf'

This command cannot get the page count and gives the below error:

identify: Postscript delegate failed `/tmp/blahblahblah.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/664.

NB: I should note that file exist in /tmp/blahblahblah.pdf path!

Why I cannot get page count via identify?

Sample files are attached in link below:
2 PDF sample file

Alireza
  • 6,497
  • 13
  • 59
  • 132
  • Firstly, Ghostscript doesn't 'merge' PDF files. It creates a new PDF file, the appearance of which should be visually identical to the input. The content may differ significantly. Secondly you've apparently supplied the two source PDF files, but not the output file, so nobody can be certain they are precisely replicating your problem. Finally, you are using a 7+ year old version of Ghostscript. Its entirely possible that a new version wouldn't have this problem (though its almost certainly not GS at fault here). However perhaps your version of identify is similarly elderly. If so, try updating – KenS Nov 26 '16 at 15:10
  • Oh, and I see that 'identlfy is part of ImageMagick, and that error suggests to me that when IM ran the produced PDF file back through Ghostscript, GS failed to read the file properly. You can try reproducing the command line that IM sends to GS yourself, and then you'll be able to read the GS output to see what's wrong. But upgrading to a less archaic version may actually solve it. – KenS Nov 26 '16 at 15:13
  • @KenS As it is on a production server I don't want to have a major change on server that could lead to PDF generation failure. Do you think that the best way is to upgrade the GS? And what do you mean by not supplying the output file? I have used `sOUTPUTFILE ` to select the output file. Is that what you mean? – Alireza Nov 27 '16 at 06:12
  • @KenS problem has been solved b downloading the ghost script source file and compiling it. Now everything works fine. Please put your comment as an answer in order to accept it. Thanks – Alireza Nov 27 '16 at 10:13

0 Answers0