ImageGear .NET v25.2 - Updated
Verify PDF Format Compliance
Developer Guide > How to Work with... > PDF > How to... > Work with PDF Format Compliance > Verify PDF Format Compliance

ImageGear .NET provides the ImGearPDFPreflight.VerifyCompliance method to validate if a PDF document was created in compliance with PDF/A or PDF/X standards.
 
This method does not change the original PDF document; it just analyzes the content of a PDF document and reports detected incompliance. The verifier report is returned as a tree, grouped by the common document part and the pages. Each node in the report tree represented by ImGearPDFPreflightReport class corresponds to an incompliance with PDF/A or PDF/X standards.

The status code of each reported incompliance node can have one of the following ImGearPDFPreflightStatusCode values:

PDF annotations can only be verified while they reside in a PDF document. Loading PDF annotation to ART will detach them from the PDF document and make them unavailable for PDF/A or PDF/X compliance validation.

The following example illustrates how a PDF document can be verified for compliance with one of the PDF standards.

PDF support needs to be initialized first for this snippet to work. To get familiar with initializing IGNET, initializing PDF support, loading a PDF, saving a PDF, and terminating PDF support, try any one of the tutorials.
C#
Copy Code
using ImageGear.Formats.PDF;

// Verification for compliance with PDF standards results.
enum CompliantResult
{
   // Document is not compliant and cannot be converted to given profile.
   CR_CANNOT_CONVERT,
   // Document is not compliant and can be converted to given profile.
   CR_CAN_BE_CONVERTED,
   // Document is compliant with given profile.
   CR_COMPLIANT
}

// Checks the document for compliance with standard.
CompliantResult IsPDFDocumentCompliantToProfile(ImGearPDFDocument igDocument, ImGearPDFPreflightProfile profile)
{
   ImGearPDFPreflightReport report;
   using(ImGearPDFPreflight preflight = new ImGearPDFPreflight((ImGearPDFDocument)igDocument))
   report = preflight.VerifyCompliance(profile, 0, -1);
   CompliantResult result;
   if (report.Code == ImGearPDFPreflightReportCodes.SUCCESS)
       result = CompliantResult.CR_COMPLIANT;
   else if (report.Status == ImGearPDFPreflightStatusCode.Fixable)
       result = CompliantResult.CR_CAN_BE_CONVERTED;
   else
       result = CompliantResult.CR_CANNOT_CONVERT;
   return result;
} 
VB.NET
Copy Code
Imports ImageGear.Formats.PDF

' Verification for compliance with PDF standards results.
Enum CompliantResult
            ' Document is not compliant and cannot be converted to given profile.
            CR_CANNOT_CONVERT
            ' Document is not compliant and can be converted to given profile.
            CR_CAN_BE_CONVERTED
            ' Document is compliant with given profile.
            CR_COMPLIANT
End Enum

' Checks the document for compliance with standard.
Private Function IsPDFDocumentCompliantToProfile(igDocument As ImGearPDFDocument, profile As ImGearPDFPreflightProfile) As CompliantResult
            Dim report As ImGearPDFPreflightReport
            Using preflight As New ImGearPDFPreflight(DirectCast(igDocument, ImGearPDFDocument))
                        report = preflight.VerifyCompliance(profile, 0, -1)
            End Using
            Dim result As CompliantResult
            If report.Code = ImGearPDFPreflightReportCodes.SUCCESS Then
                        result = CompliantResult.CR_COMPLIANT
            ElseIf report.Status = ImGearPDFPreflightStatusCode.Fixable Then
                        result = CompliantResult.CR_CAN_BE_CONVERTED
            Else
                        result = CompliantResult.CR_CANNOT_CONVERT
            End If
            Return result
End Function
Is this page helpful?
Yes No
Thanks for your feedback.