ImageGear v26.5 - Updated
Developer Guide / How to Work with ... / PDF / How to... / Work with PDF Format Compliance / Convert to Compliant PDF
In This Topic
    Convert to Compliant PDF
    In This Topic

    ImageGear .NET provides the ImGearPDFPreflight.Convert method to run an automatic PDF to PDF/A conversion.

    This method consumes the original PDF document and produces a new ImGearPDFDocument that adheres to the specified conformance profile, as long as the input document is "fixable."

    If the input document cannot be converted, the ImGearPDFPreflightConversionResult returned from the Convert method will have a Success value of false, and additional details can be retrieved using the Description property.

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

    Saving PDF/A Documents

    PDF/A documents can be saved just the same as any other ImGearPDFDocument object. See how to save a pdf.

    The following example illustrates how a PDF document can be converted to a PDF document compliant with the PDF/A-2b standard.

    C#

    // Create an ImGearPDFPreflight object from the source ImGearPDFDocument object, pdfDoc.
    using ImGearPDFPreflight preflight = new ImGearPDFPreflight(pdfDoc);
    
    // Create an ImGearPDFPreflightConversionOptions object for profile PDF/A-2B
    // with 300 DPI fallback rasterization resolution.
    using ImGearPDFPreflightConversionOptions options = new ImGearPDFPreflightConversionOptions(
        ImGearPDFPreflightProfile.PDFA_2B_2011, 300);
    
    // Attempt to create a new ImGearPDFDocument object from pdfDoc that is PDF/A-2B compliant.
    ImGearPDFPreflightConversionResult result = preflight.Convert(options);
    try
    {
        // Save the resulting PDF/A-2B compliant ImGearPDFDocument to a file.
        if (result.Succeeded)
            result.Document.Save(outputPath, ImGearSavingFormats.PDF, 0, 0,
                (int)ImGearPDFPageRange.ALL_PAGES, ImGearSavingModes.OVERWRITE);
    }
    finally
    {
        // Dispose of the resulting ImGearPDFDocument.
        result.Document?.Dispose();
    }