Convert PDF to PDF/A in C#

To archive electronic documents with long-term preservation, you’ll need to convert your source PDF document to a PDF/A document intended for archiving.

For more information on the long-term preservation of documents, check out our demo video below.

Our native PDF-to-PDF/A converter parses the source document and compares the document structure to the expected conformance level. The document can be modified to conform to the specification by adding, editing, or removing required document structure elements; embedding fonts, if possible; and using other techniques.

If such a conversion by direct modification isn’t possible, the PDF-to-PDF/A conversion engine falls back to secondary conversion options, which are vectorization and rasterization. Both these options perform rendering of the document content into a completely new document. Vectorization produces vector-based graphic elements where applicable — for example, fonts and paths — and combines them with image resources. Meanwhile, rasterization renders the document content using the raster (pixel-based) approach.

Both the vectorization and rasterization approaches result in loss of fonts and text information because the text converts into shapes and raster images. Text information can later be recovered using OCR.

The code below demonstrates the basic workflow for this conversion. You can choose the PDF conformance level and approach required:

// We assume GdPicture has been correctly installed and unlocked.
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    // Loading a PDF document to convert.
    GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
    if (status == GdPictureStatus.OK)
    {
        // Providing the conversion to a PDF/A-1b-conforming document.
        status = gdpicturePDF.ConvertToPDFA("converted.pdf", PdfConversionConformance.PDF_A_1b, true, true);
        if (status == GdPictureStatus.OK)
        {
            MessageBox.Show("The PDF file has been converted successfully.", "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Information);
            // Checking the conformance of the converted document.
            using (GdPicturePDF convertedPDF = new GdPicturePDF())
            {
                status = convertedPDF.LoadFromFile("converted.pdf", false);
                if (status == GdPictureStatus.OK)
                {
                    PdfConformance conf = convertedPDF.GetPDFAConformance();
                    MessageBox.Show("The conformance of newly created PDF is: " + conf.ToString(), "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                convertedPDF.CloseDocument();
                // You can validate the resulting document using available PDF/A validators.
            }
        }
        else
            MessageBox.Show("The file can't be converted. Status: " + status.ToString(), "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
        gdpicturePDF.CloseDocument();
    }
    else
        MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
'We assume GdPicture has been correctly installed and unlocked.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    'Loading a PDF document to convert.
    Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
    If status = GdPictureStatus.OK Then
        'Providing the conversion to a PDF/A-1b-conforming document.
        status = gdpicturePDF.ConvertToPDFA("converted.pdf", PdfConversionConformance.PDF_A_1b, True, True)
        If status = GdPictureStatus.OK Then
            MessageBox.Show("The PDF file has been converted successfully.", "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Information)
            'Checking the conformance of the converted document.
            Using convertedPDF As GdPicturePDF = New GdPicturePDF()
                status = convertedPDF.LoadFromFile("converted.pdf", False)
                If status = GdPictureStatus.OK Then
                    Dim conf As PdfConformance = convertedPDF.GetPDFAConformance()
                    MessageBox.Show("The conformance of newly created PDF is: " + conf.ToString(), "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
                convertedPDF.CloseDocument()
                'You can validate the resulting document using available PDF/A validators.
            End Using
        Else
            MessageBox.Show("The file can't be converted. Status: " + status.ToString(), "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
        gdpicturePDF.CloseDocument()
    Else
        MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), "Conversion to PDF/A Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End If
End Using