How can I verify that a PDF file is “good”?

Question:

I have a process that compresses PDF files that our secretaries create by scanning signed documents at a multi-function printer.

On rare occasions, these files cannot be opened in Acrobat reader after being compressed. I don’t know why this is happening rarely, so I’d like to be able to test the PDF post-compression and see if it is “good”.

I am trying to use itextsharp 5.1.1 to accomplish this, but it happily loads the PDF. My best guess is that Acrobat reader fails when it’s trying to display the picture.

Any ideas on how I can tell if the PDF will render?

Answer:

OK, what I ended up doing was using itextsharp to loop through all of the stream objects and check their length. The error condition I had was that the length would be zero. This test seems quite reliable. It may not work for everyone, but it worked in this particular situation.

Source:

How can I verify that a PDF file is “good”? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply