We help IT Professionals succeed at work.

check if a PDF file is corrupt in C#

dlsimic
dlsimic asked
on
1,959 Views
Last Modified: 2014-08-08
I need to validate that a PDF is not corrupt.  Any ideas?
Comment
Watch Question

Senior Developer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Can you think of anything without commercial licensing?
ste5anSenior Developer
CERTIFIED EXPERT

Commented:
What commercial licensing? It's AGPL.

Author

Commented:
Maybe I am reading the licensing wrong.  But it appears that if I were to distribute code with this dll in it then I need to have a commercial license.

This statement is taken from their website:
"Buying a commercial license is mandatory as soon as you begin activities including distribution of iText software inside your product or deploying it on a network without disclosing the source code of your own applications under the AGPL license."
ste5anSenior Developer
CERTIFIED EXPERT

Commented:
Please post a link...
CERTIFIED EXPERT

Commented:
Hmmm - the Adobe Acrobat Reader comes with some kind of ActiveX control you could bind into a VS application as PDF viewer (that way you could i.e. view some kind of help PDF within your application). I think it's a s free as the reader itself.

Just add the appropriate reference in Visual Studio to access it.

Try to load the file in this and it should throw an exception if the file is too corrupted to load. Anyhow I would expect possible that a file is corrupted in a way that allows it to load but displays garbage anyhow. In that case you'd have to implement a full blown PDF syntax parser to detect flaws ;-)
ste5anSenior Developer
CERTIFIED EXPERT

Commented:
Yup, read it again. It's free as long as you respect AGPL:

While the AGPL license has no direct financial cost, there are clear requirements for AGPL use. Buying a commercial license is mandatory as soon as you develop activities involving the iText software without disclosing the source code of your own applications.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.