Reputation: 34071
I have a corrupted pdf file and want to know, if ghostscript will recognize it.
With following statement, I tried to configure it out, if pdf is corrupt or not:
gs \
-o /dev/null \
-sDEVICE=nullpage \
/path/to/corrupt.pdf
The statement echo $?
return always 0. I can't even open the pdf file with acrobat reader.
Why gs does not recognize it? Or is there an alternativ to ghostscript?
Upvotes: 0
Views: 952
Reputation: 31139
Ghostscript, like Acrobat, attempts to ignore errors in PDF files.
Why ? Because if we don't people send us their crappy broken PDF files and say 'But Acrobat can open it'.....
If you specify -dPDFSTOPONERROR then Ghostscript will instead throw an error on a large (but by no means exhaustive) range of broken PDF files.
Note that the Ghostscript exit code does not ordinarily tell you if a PostScript (or in fact PDF) error occurred, the interpreter tells you that on the back channel. Ghostscript exit codes usually only tell you when something catastrophic happened to the interpreter (eg it ran out of memory).
Ghostscript is not a PDF validation tool.
Upvotes: 1