How to Convert PDF to PDF/A in C#, VB.NET

PDF/A standard is based on Adobe PDF version 1.4, which ensures that the PDF document will look the same when it is accessed or processed in years to come. The standard specifies two levels of compliance for PDF files: PDF/A-1a and PDF/A-1b. What Spire.PDF support is to convert most of your PDF documents to become compliant with the PDF/A-1b. In the following section, let’s see detailed steps of how to convert PDF to PDF/A-1b compliant PDF suing Spire.PDF in C#, VB.NET.

Detailed Steps:

Step 1: Initialize a new instance of PdfDocument class and load the sample file.

PdfDocument OriginalDoc = new PdfDocument();
OriginalDoc.LoadFromFile("sample.pdf");

Step 2: Create a new object of PdfNewDocument class, set the PDF conformance level as PDF/A-1b.

PdfNewDocument newDOC = new PdfNewDocument();
newDOC.Conformance = PdfConformanceLevel.Pdf_A1B;

Step 3: Clone page sizes and contents from the original document to the new PDF document.

foreach (PdfPageBase page in OriginalDoc.Pages)
{
    SizeF size = page.Size;
    PdfPageBase p = newDOC.Pages.Add(size, new Spire.Pdf.Graphics.PdfMargins(0));
    page.CreateTemplate().Draw(p, 0, 0);
}

Step 4: Save the file and launch to view the effect.

newDOC.Save("result.pdf");
System.Diagnostics.Process.Start("result.pdf");

Result:

How to Convert PDF to PDF/A in C#, VB.NET

Full Code:

[C#]
PdfDocument OriginalDoc = new PdfDocument();
OriginalDoc.LoadFromFile("sample.pdf");

PdfNewDocument newDOC = new PdfNewDocument();
newDOC.Conformance = PdfConformanceLevel.Pdf_A1B;
foreach (PdfPageBase page in OriginalDoc.Pages)
{
    SizeF size = page.Size;
    PdfPageBase p = newDOC.Pages.Add(size, new Spire.Pdf.Graphics.PdfMargins(0));
    page.CreateTemplate().Draw(p, 0, 0);
}

newDOC.Save("result.pdf");
System.Diagnostics.Process.Start("result.pdf");
[VB.NET]
Dim OriginalDoc As New PdfDocument()
OriginalDoc.LoadFromFile("sample.pdf")

Dim newDOC As New PdfNewDocument()
newDOC.Conformance = PdfConformanceLevel.Pdf_A1B
For Each page As PdfPageBase In OriginalDoc.Pages
	Dim size As SizeF = page.Size
	Dim p As PdfPageBase = newDOC.Pages.Add(size, New Spire.Pdf.Graphics.PdfMargins(0))
	page.CreateTemplate().Draw(p, 0, 0)
Next

newDOC.Save("result.pdf")
System.Diagnostics.Process.Start("result.pdf")