0

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?

1
  • Does gs print any errors? Can you view it when you leave out -o ... -sDEVICE=... ? Are there any (orhter) errors or a return code then? What will file /path/to/corrupt.pdf say? If you're lucky enough, it is so corrupt that it won't be even recognizable as pdf. Commented Aug 31, 2016 at 15:15

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

do you know any pdf validation tool?
Its off-topic for Stack Overflow because that isn't a programming question. However a Google search of 'PDF validation tool' turned up several possibilities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.