Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
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
Further Reading: How to Export PDF/UA Format Documents in C#