In today's world, document management and long-term storage play a key role in business, legal practice, government agencies, and other fields. Archiving standards such as PDF/A have provided reliable, consistent, and convenient storage of electronic documents for decades. In this context, automating the process of converting documents to PDF/A format is becoming an indispensable task for developers and system integrators.
In this article, we will explain in detail how to implement PDF/A conversion using C# and .NET, using the powerful the SautinSoft Pdf .Net library. Let's describe the advantages of this approach, consider the practical application, and give recommendations on how to use it.
PDF/A is an international standard (ISO 19005-1) designed for long—term storage of electronic documents in PDF format. The main difference from regular PDF is that PDF/A eliminates potentially unused or outdated elements, provides embedded fonts, metadata, and other mechanisms that ensure document recoverability after decades. This format is used in archiving emails and reports, in accounting documents, as well as storing contracts and contracts.
Advantages of PDF/A:
Manual is inefficient with file volumes, error-prone, and time-consuming. Automating the process using the program code allows you to:
Complete code
using System;
using System.IO;
using System.Reflection;
using SautinSoft;
using SautinSoft.Pdf;
using SautinSoft.Pdf.Content;
namespace Sample
{
class Sample
{
/// <summary>
/// Convert PDF to PDF/A using C# and .NET.
/// </summary>
/// <remarks>
/// Details: https://sautinsoft.com/products/pdf/help/net/developer-guide/convert-pdf-to-pdfa-using-csharp-and-dotnet.php
/// </remarks>
static void Main(string[] args)
{
// Before starting this example, please get a free trial key:
// https://sautinsoft.com/start-for-free/
// Apply the key here:
// PdfDocument.SetLicense("...");
// Load a PDF document.
using (var document = PdfDocument.Load(Path.GetFullPath(@"..\..\..\simple text.pdf")))
{
// Create PDF save options.
var pdfOptions = new PdfSaveOptions()
{
// PDF/A-1: Published October 2005 as ISO 19005-1 and based on PDF 1.4.
// PDF/A-2: Published June 2011 as ISO 19005-2 and based on PDF 1.7 (ISO 32000-1:2008).
// PDF/A-3: Published October 2012 as ISO 19005-3 and based on PDF 1.7 (ISO 32000-1:2008).
// PDF/A-4 has been published in 2020 as ISO 19005-4. Based on PDF 2.0.
// Select the desired PDF/A version.
Version = PdfVersion.PDF_A_4E
};
// Save a PDF document.
document.Save("Convert to PDF-A.pdf", pdfOptions);
}
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"Convert to PDF-A.pdf") { UseShellExecute = true });
}
}
}
Option Infer On
Imports System
Imports System.IO
Imports System.Reflection.Metadata
Imports SautinSoft
Imports SautinSoft.Pdf
Imports SautinSoft.Pdf.Content
Namespace Sample
Friend Class Sample
''' <summary>
''' Convert PDF to PDF/A using C# and .NET.
''' </summary>
''' <remarks>
''' Details: https://sautinsoft.com/products/pdf/help/net/developer-guide/convert-pdf-to-pdfa-using-csharp-and-dotnet.php
''' </remarks>
Shared Sub Main(ByVal args() As String)
' Before starting this example, please get a free trial key:
' https://sautinsoft.com/start-for-free/
' Apply the key here:
' PdfDocument.SetLicense("...");
' Load a PDF document.
Using document = PdfDocument.Load(Path.GetFullPath("..\..\..\simple text.pdf"))
' Create PDF save options.
Dim pdfOptions = New PdfSaveOptions() With {.Version = PdfVersion.PDF_A_4E}
' Save a PDF document.
document.Save("Convert to PDF-A.pdf", pdfOptions)
End Using
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo("Convert to PDF-A.pdf") With {.UseShellExecute = True})
End Sub
End Class
End Namespace
If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: