How to Export PDF UA Format Documents in C#

In this tutorial, we explore how to export PDF/UA-compliant documents using Iron PDF in C#. The process begins with installing Iron PDF through the NuGet package manager, followed by setting up the IronPDF library in the Program.cs file. After adding the IronPDF license key, the tutorial demonstrates how to load an existing PDF file (e.g., Wikipedia.pdf) using the FromFile method. The key operation involves using the SaveAsPdfUA method to convert and save the document as a PDF/UA-compliant file. The tutorial concludes by running the program and validating the output PDF to ensure compliance. This step-by-step guide is ideal for developers looking to leverage Iron PDF's functionality in C# for creating accessible PDF documents. For those new to Iron PDF, the tutorial encourages trying out the software with a provided download link.

Here's a walkthrough of the necessary code implementation:

// Import the IronPDF library
using IronPdf;

class Program
{
    static void Main(string[] args)
    {
        // Define the path to the PDF file you want to load
        string pdfPath = "Wikipedia.pdf";

        // Load the existing PDF file
        PdfDocument pdfDocument = PdfDocument.FromFile(pdfPath);

        // Check the loading status for debugging purposes
        if (pdfDocument != null)
        {
            Console.WriteLine("PDF loaded successfully.");
        }

        // Define the path to save the PDF/UA compliant document
        string pdfUaPath = "Wikipedia_PDFUA.pdf";

        // Convert and save the existing PDF as a PDF/UA compliant document
        pdfDocument.SaveAsPdfUA(pdfUaPath);

        // Confirm the PDF has been saved
        Console.WriteLine($"PDF/UA compliant document saved at: {pdfUaPath}");
    }
}
// Import the IronPDF library
using IronPdf;

class Program
{
    static void Main(string[] args)
    {
        // Define the path to the PDF file you want to load
        string pdfPath = "Wikipedia.pdf";

        // Load the existing PDF file
        PdfDocument pdfDocument = PdfDocument.FromFile(pdfPath);

        // Check the loading status for debugging purposes
        if (pdfDocument != null)
        {
            Console.WriteLine("PDF loaded successfully.");
        }

        // Define the path to save the PDF/UA compliant document
        string pdfUaPath = "Wikipedia_PDFUA.pdf";

        // Convert and save the existing PDF as a PDF/UA compliant document
        pdfDocument.SaveAsPdfUA(pdfUaPath);

        // Confirm the PDF has been saved
        Console.WriteLine($"PDF/UA compliant document saved at: {pdfUaPath}");
    }
}
' Import the IronPDF library
Imports IronPdf

Friend Class Program
	Shared Sub Main(ByVal args() As String)
		' Define the path to the PDF file you want to load
		Dim pdfPath As String = "Wikipedia.pdf"

		' Load the existing PDF file
		Dim pdfDocument As PdfDocument = PdfDocument.FromFile(pdfPath)

		' Check the loading status for debugging purposes
		If pdfDocument IsNot Nothing Then
			Console.WriteLine("PDF loaded successfully.")
		End If

		' Define the path to save the PDF/UA compliant document
		Dim pdfUaPath As String = "Wikipedia_PDFUA.pdf"

		' Convert and save the existing PDF as a PDF/UA compliant document
		pdfDocument.SaveAsPdfUA(pdfUaPath)

		' Confirm the PDF has been saved
		Console.WriteLine($"PDF/UA compliant document saved at: {pdfUaPath}")
	End Sub
End Class
$vbLabelText   $csharpLabel

Further Reading: How to Export PDF/UA Format Documents in C#

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.
< PREVIOUS
How to Debug HTML in Chrome to Create Pixel Perfect PDFs
NEXT >
How to Convert PDF to PDF A in C# Using IronPDF
OSZAR »