I need to optimize several large PDF documents for file size, so I tried using it ghostscript, it gets called like this:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH -sOutputFile=output-my-doc.pdf input-my-doc.pdf
I see that this works for some pages, but then on separate pages it crashes.
I upgraded to gsversion 9.02 and I experienced the same thing. After tearing the document into separate pages and executing the above command on each page, I can confirm which pages are problematic; in fact, an error occurs even if I call only gs input-my-doc-pageX.pdf- this launches the viewer, and I could see the typing until it hit the image when it crashed.
Therefore, I could confirm that in my case it gsfalls on certain images - and finally, I can also provide a minimal working (or rather, non-working) example that demonstrates the problem (see below). In particular, the problem is 8-bit RGB images defined in a certain way.
Now I can’t say if this is a mistake, but since I need to do this - I thought that maybe I could "cheat" ghostscriptby running PDF files through the application, which would largely leave the PDF files untouched - for except that it will transcode images into one format (say, PNG); so that the optimizer gscan work on these files without crashing.
PDF Linux?
,
!
PS: : Imagemagick: PDF flate?.
, PDF (hello2.pdf) , , evince:

... xref- , :
$ pdftk hello2.pdf output hello2O.pdf
$ qpdf --check hello2O.pdf
checking hello2O.pdf
PDF Version: 1.4
File is not encrypted
File is not linearized
No errors found
hello2O.pdf evince - , gs, :
$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH -sOutputFile=optihello2O.pdf hello2O.pdf
GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 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
Loading NimbusSanL-Regu font from /usr/share/ghostscript/9.02/Resource/Font/NimbusSanL-Regu... 2756020 1410650 1869284 568021 3 done.
Error: /undefined in
Operand stack:
Execution stack:
%interp_exit .runexec2
Dictionary stack:
Current allocation mode is local
GPL Ghostscript 9.02: Unrecoverable error, exit code 1