check if a PDF file is corrupt in C#

I need to validate that a PDF is not corrupt.  Any ideas?
dlsimicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Take a look at iTextSharp.. Load it. When corrupted, then it should throw an appropriate exception.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dlsimicAuthor Commented:
Can you think of anything without commercial licensing?
0
ste5anSenior DeveloperCommented:
What commercial licensing? It's AGPL.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

dlsimicAuthor 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."
0
ste5anSenior DeveloperCommented:
Please post a link...
0
dlsimicAuthor Commented:
0
frankhelkCommented:
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 ;-)
0
ste5anSenior DeveloperCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.