views:

43

answers:

1

On a particular PDF, when running the following command:

gs -dSAFER -dBATCH -dNOPAUSE -dQUIET -dFirstPage=1 -dLastPage=1 -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

I get this error:

GPL Ghostscript 8.71: Warning: 'loca' length 188 is greater than numGlyphs 93 in the font MGOXZX+Arial-BoldMT.

Any ideas what this error means and how to resolve the issue?

A: 

First, Ghostscript didn't declare this as an 'error', but a 'warning'. That's quite a difference.

Second, you asked Ghostscript to output the first page of a PDF input. Did it work? Do you see any visible differences when comparing output.pdf and first page of input.pdf?

Third, if there's really a problem, you should indicate which Ghostscript version you're running. The most recent one is 8.71.


Update: Of course, StackOverflowNewbie had already hinted at the version of Ghostscript by quoting the warning message...

"Warning" means: there may be a problem with the output file (which in itself still is a valid PDF), but you better check it.

"Error" means: there surely is a problem with the output, and Ghostscript will abort all further processing; the output is very likely not even a valid PDF.

There are a lot of different methods to further debug the problem. But it is impossible to give any nail hitting advice if you don't see the files in question. StackOverflowNewbie reports the output page to look different from the input.

So here's the sledgehammer to use: add -dDEBUG to the commandline:

gs \
  -sOutputFile=output.pdf \
  -dDEBUG \
  -dLastPage=1 \
  -sDEVICE=pdfwrite \
   input.pdf

Caveats! This will potentially produce an enormous amount of stderr/stdout output in your console.

If you already know or have a certain clue where the exact problem may be rooted (which you could probably even directly assume from looking at the visual differences between input and output PDF), you could narrow it down by using (instead of -dDEBUG) one of the following, in order:

 -dPDFDEBUG      # (debug PDF Interpreter)
 -dPDFWRDEBUG    # (debug PDF Writer)
 -dTTFDEBUG      # (debug TTF Fonts)
 -dCCFONTDEBUG   # (debug compiled-in Fonts)
 -dFAPIDEBUG     # (debug Font API)
 -dCFFDEBUG      # (debug CFF Fonts)
 -dCMAPDEBUG     # (debug CMAP)
 -dDOCIEDEBUG    # (debug CIE color)
 -dSETPDDEBUG    # (debug setpagedevice)
 -dSTRESDEBUG    # (debug Static Resources)
 -dVGIFDEBUG     # (debug ViewGIF)
 -dVJPGDEBUG     # (debug ViewJPEG)
 -dINITDEBUG     # (debug Initialization)
 -dEPSDEBUG      # (debug EPS handling)
 -dPDFOPTDEBUG   # (debug PDF Optimizer/Linearizer)

Also, since the warning mentions font Arial-BoldMT, you should first check the status of font embedded-ness of both, input and output pages with the help of pdfinfo and pdffonts:

 pdfinfo -f 1 -l 1 -box input.pdf
 pdfinfo -box output.pdf
 pdffonts -f 1 -l 1 input.pdf
 pdffonts output.pdf

Update2:

You could try to extract the font(s) from the original PDF for further investigation. (If you don't know how to do this, ask new, separate SO questions such as "How can I extract fonts from a PDF for further analysis?" and "How can I investigate a font for internal faults?")

pipitas
1. How does GS differentiate between "error" and "warning?" 2. There was a significant difference in the output: the output didn't have the textual content of the original document. 3. the "warning" already shows the version: 8.71.
StackOverflowNewbie
D'oh! There it was in plain sight, but I didn't see it...(v8.71). -- "Warning" means: a valid output document will still be produced; but better check it. "Error" means: the output for sure is not as you wanted. I'll update my answer...
pipitas