Starting in 10.4, DotImage's PdfDocument components have a new Examiner tool. It allows a very fast, low-overhead means to probe a PDF to ascertain useful information such as whether the file is a valid PDF, if it contains certain structures or types that we do not support, if it has forms data, etc.
Making use of Examiner
First, you will need to make sure to add a reference to Atalasoft.PdfDoc.dll to your project.
You will need a license for DotImage Document Imaging or DotPdf to use this component (you do NOT need a license for PdfReader to use Examiner)
add the required using/Imports statement
C#:
using Atalasoft.PdfDoc.Examiner;
VB.NET:
Imports Atalasoft.PdfDoc.Examiner
Now, you're ready to use the Examiner to analyze the PDF - you'll need a stream to pass to it. Support strongly suggests that you wrap your stream in a using statement as this will guarantee you don't leave a file handle open on your PDF file accidentally.
C#:
using
(FileStream fs = new FileStream(@"Path\to\target.pdf", FileMode.Open))
{
ExaminerResults res = ExaminerResults.FromStream(fs, null, null);
// you can now access various properties of the results to check for desired attributes
}
VB.NET:
Using fs As New FileStream("Path\to\target.pdf", FileMode.Open)
Dim res As ExaminerResults = ExaminerResults.FromStream(fs, Nothing, Nothing)
' you can now access various properties of the results to check for desired attributes
End Using
Sample Project
PdfDocExaminerExample.zip is attached to this article - it's a simple console app that shows a practical implementation this component.