ImageGear .NET - Updated
Convert to Compliant PDF
User Guide > How to Work with... > Formats with Additional Functionality > PDF > How to... > Work with PDF Format Compliance > Convert to Compliant PDF

ImageGear .NET provides the ImGearPDFPreflight.Convert method to run an automatic PDF to PDF/A conversion, with or without preceding verification.

This method changes the original PDF document (in memory) by fixing all Fixable incompliance nodes. If all incompliance nodes in a PDF document are fixable, that PDF document will be converted into a PDF/A compliant document. The converter 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 incompliance with PDF/A standard. All fixed incompliance nodes in the report provide details of the corresponding fix.

Raster to PDF/A

This version of the ImageGear .NET PDF component allows PDF to PDF/A conversion for all PDF files produced directly from raster files by saving them to PDF with ImageGear .NET. The following automatic fixes are done during this conversion:

Problem Area

Fix Description

OutputIntent

All uncalibrated color spaces are replaced with a provided color profile (must be RGB or CMYK). Note that images may be converted to a new color space, which could change the file size. Particularly, the bit depth and compression of the 1-bit images will be changed to either 24- or 32-bits per pixel.
LZW and JPEG 2000 Compression

Since LZW and JPEG 2000 compressions are prohibited in PDF/A compliant files, all LZW and JPEG 2000 streams in PDF document are recompressed, which would change the file size.

Header and Metadata

ImageGear .NET automatically fills in all values in PDF document headers to ensure PDF/A compliance.

Saving PDF/A Documents

There are two ways to save converted PDF/A documents. Choose one of the following methods described below that best fits into your current workflow:

ImGearFileFormats.SaveDocument Method

If you need to convert a PDF document to PDF/A quickly, without displaying it or otherwise working with it, then saving the PDF document with the ImGearFileFormats.SaveDocument method is the best choice. See the Load and Save a PDF topic for an example on how to convert a document to PDF/A using this method.

The saveOptions parameter of the ImGearFileFormats.SaveDocument method must not be null, and the ImGearPDFSaveOptions.PreflightOptions property must be set for the saved PDF to be PDF/A compliant. This is true even if the ImGearPDFPreflight.Convert method was called manually on the PDF document prior to saving it. If no PreflightOptions are specified, then the saved PDF will not be PDF/A compliant.

ImGearDocument.Save Method

Alternatively, the ImGearPDFDocument.Save method can be used if your application uses a manual process for converting PDF documents to PDF/A or performs other actions on the PDF opened in memory. In this case, the ImGearPDFPreflight.Convert method must be called on the document before it is saved. When you are ready, call the ImGearPDFDocument.Save method to save the changes in the PDF/A document to a file or memory stream.

This process is convenient when using ImageGear.Recognition to create searchable image PDFs that are PDF/A compliant. See the Exporting to a PDF Output Document topic for an example of how to do this.

The following example illustrates how a PDF document can be converted to a PDF document compliant with the PDFA-1a standard.

C#
Copy Code
// ImGearPDFPreflightProfile.PDFA_1A_2005 is the constant value for checking for PDFA-a1 standard. It may be changed for checking for other standards,
       // e.g. PDFA_1A_2005, PDFA_1B_2005, PDFX_3_2003.
       ImGearPDFPreflightConvertOptions conversionOptions = new ImGearPDFPreflightConvertOptions(ImGearPDFPreflightProfile.PDFA_1A_2005, 0, -1);

       // Convert PDF document to PDFA
       void ConvertPdfToCompliantWithPDFA(ImGearPDFDocument pdfDocument)
       {
           ImGearPDFPreflightReport report;
           // Perform conversion of PDF document to PDFA-1a standard.
           using (ImGearPDFPreflight preflight = new ImGearPDFPreflight((ImGearPDFDocument)pdfDocument))
               report = preflight.Convert(conversionOptions);
           // Create error message if document was not converted.
           if (report.Status != ImGearPDFPreflightStatusCode.Fixed)
               throw new ApplicationException("Given PDF document cannot be converted to PDFA-1a standard.");
       }
VB.NET
Copy Code
' ImGearPDFPreflightProfile.PDFA_1A_2005 is the constant value for checking for PDFA-a1 standard. It may be changed for checking for other standards,
' e.g. PDFA_1A_2005, PDFA_1B_2005, PDFX_3_2003.
Private conversionOptions As New ImGearPDFPreflightConvertOptions(ImGearPDFPreflightProfile.PDFA_1A_2005, 0, -1)

' Convert PDF document to PDFA
Private Sub ConvertPdfToCompliantWithPDFA(pdfDocument As ImGearPDFDocument)
            Dim report As ImGearPDFPreflightReport
            ' Perform conversion of PDF document to PDFA-1a standard.
            Using preflight As New ImGearPDFPreflight(DirectCast(pdfDocument, ImGearPDFDocument))
                        report = preflight.Convert(conversionOptions)
            End Using
            ' Create error message if document was not converted.
            If report.Status <> ImGearPDFPreflightStatusCode.Fixed Then
                        Throw New ApplicationException("Given PDF document cannot be converted to PDFA-1a standard.")
            End If
End Sub