How To Test If A PDF Is Valid



TODO:  

Have you ever wanted to test that a PDF was actually a valid PDF?

 

SOLUTION:

try
{
      reader = new PdfReader("mypdf.pdf");
}
catch (iTextSharp.text.exceptions.InvalidPdfException ex)
{
     //do some stuff here, like move to an error folder maybe?                           
}

 

NOTES:

You can download iTextSharp from SourceForge.net