DEV Community

IronSoftware
IronSoftware

Posted on

Convert PDF to PDF/A for Archival in C# (.NET Guide)

Our legal department lost access to 10-year-old contracts. Fonts were missing, embedded videos broke, colors rendered wrong. The PDFs were technically valid but practically unusable.

PDF/A solved this. It's the archival standard that ensures documents remain readable decades later. Here's the conversion.

What Is PDF/A?

PDF/A is an ISO standard (ISO 19005) for long-term archival. It enforces rules that ensure PDFs remain viewable forever:

  • Fonts must be embedded
  • No external dependencies
  • No encryption
  • No JavaScript
  • Color spaces must be device-independent
using IronPdf;
// Install via NuGet: Install-Package IronPdf

var pdf = PdfDocument.FromFile("document.pdf");
pdf.ToPdfA();
pdf.SaveAs("archive.pdf");
Enter fullscreen mode Exit fullscreen mode

The resulting PDF/A file is self-contained and future-proof.

Why Use PDF/A?

Standard PDFs can break over time:

  • Fonts unavailable → text renders incorrectly
  • Color profiles lost → colors shift
  • External links dead → content inaccessible
  • Software bugs → rendering failures

PDF/A prevents these issues. Documents look identical 50 years from now.

Industries requiring PDF/A:

  • Legal (court filings, contracts)
  • Healthcare (medical records)
  • Government (official documents)
  • Finance (tax records, audits)

What Are the PDF/A Versions?

PDF/A-1: Based on PDF 1.4 (2005). Most restrictive.
PDF/A-2: Based on PDF 1.7 (2011). Allows layers, transparency.
PDF/A-3: Allows embedded files (attachments).

Sub-levels:

  • -a: Accessible (tagged for screen readers)
  • -b: Basic (visual appearance only)
  • -u: Unicode (searchable text)

IronPDF supports PDF/A-2b and PDF/A-3b by default.

How Do I Convert Existing PDFs to PDF/A?

Use ToPdfA():

var pdf = PdfDocument.FromFile("standard.pdf");
pdf.ToPdfA();
pdf.SaveAs("archive.pdf");
Enter fullscreen mode Exit fullscreen mode

IronPDF embeds fonts, removes JavaScript, fixes color spaces automatically.

Can I Generate PDF/A Directly from HTML?

Yes. Set metadata before rendering:

var renderer = new [ChromePdfRenderer](https://ironpdf.com/blog/videos/how-to-render-html-string-to-pdf-in-csharp-ironpdf/)();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

var pdf = renderer.RenderHtmlAsPdf("<h1>Archival Document</h1>");
pdf.ToPdfA();
pdf.SaveAs("archive.pdf");
Enter fullscreen mode Exit fullscreen mode

Or convert immediately after generation.

What If Conversion Fails?

Some PDFs can't convert to PDF/A:

  • Encrypted PDFs
  • PDFs with missing fonts
  • PDFs using unsupported features

Check for errors:

try
{
    var pdf = PdfDocument.FromFile("problematic.pdf");
    pdf.ToPdfA();
    pdf.SaveAs("archive.pdf");
}
catch (Exception ex)
{
    Console.WriteLine($"PDF/A conversion failed: {ex.Message}");
    // Log error, alert admin
}
Enter fullscreen mode Exit fullscreen mode

Common fixes:

  • Remove encryption first
  • Regenerate PDF from source with embedded fonts
  • Use PDF/A-3b instead of PDF/A-1a (less restrictive)

How Do I Verify PDF/A Compliance?

Adobe Acrobat shows "PDF/A mode" in the document bar for compliant files.

Programmatically check metadata:

var pdf = PdfDocument.FromFile("archive.pdf");

// Check if PDF/A compliant
bool isCompliant = pdf.MetaData.Title.Contains("PDF/A");

// Verify version
Console.WriteLine($"PDF Version: {pdf.Version}");
Enter fullscreen mode Exit fullscreen mode

Third-party validators like veraPDF provide comprehensive compliance checks.

Does PDF/A Increase File Size?

Yes, typically 10-30% larger due to:

  • Embedded fonts (not subsetted)
  • Embedded color profiles
  • Metadata overhead

A 1MB standard PDF becomes ~1.2MB as PDF/A.

For archival, the size trade-off is worth the guaranteed readability.

Can I Convert PDF/A Back to Standard PDF?

Yes, but you lose archival guarantees:

var pdfA = PdfDocument.FromFile("archive.pdf");

// Remove PDF/A metadata (no direct API, requires re-rendering)
var renderer = new ChromePdfRenderer();
var html = pdfA.ExtractAllText(); // Simplified example
var standard = renderer.RenderHtmlAsPdf(html);

standard.SaveAs("standard.pdf");
Enter fullscreen mode Exit fullscreen mode

This removes PDF/A constraints but isn't lossless.

How Do I Batch Convert to PDF/A?

Loop through files:

var files = Directory.GetFiles("documents", "*.pdf");

foreach (var file in files)
{
    var pdf = PdfDocument.FromFile(file);

    try
    {
        pdf.ToPdfA();
        pdf.SaveAs(file.Replace(".pdf", "-pdfa.pdf"));
        Console.WriteLine($"Converted: {file}");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Failed: {file} - {ex.Message}");
    }
}
Enter fullscreen mode Exit fullscreen mode

I converted 5,000+ legal documents to PDF/A for long-term storage using this pattern.

What About PDF/A-3 with Embedded Files?

PDF/A-3 allows attachments (useful for including source data):

var pdf = PdfDocument.FromFile("report.pdf");

// Add source data as attachment
var data = File.ReadAllBytes("data.xml");
pdf.Attachments.AddAttachment("SourceData", data);

// Convert to PDF/A-3
pdf.ToPdfA();
pdf.SaveAs("report-pdfa3.pdf");
Enter fullscreen mode Exit fullscreen mode

The attachment is preserved in the archival PDF.

Does PDF/A Support Forms?

PDF/A-1 doesn't allow interactive forms. PDF/A-2 and PDF/A-3 support forms, but they're flattened (not editable).

For archival with forms, use PDF/A-2b or PDF/A-3b.

How Do I Handle Color Profiles?

PDF/A requires device-independent color spaces (RGB, CMYK with embedded profiles). IronPDF handles this automatically during conversion.

If your PDF uses spot colors or device-dependent colors, conversion may alter appearance slightly to meet PDF/A requirements.

Can I Add Metadata to PDF/A?

Yes, metadata is required for PDF/A:

var pdf = PdfDocument.FromFile("document.pdf");

pdf.MetaData.Title = "Annual Report 2024";
pdf.MetaData.Author = "Acme Corporation";
pdf.MetaData.Subject = "Financial Statements";
pdf.MetaData.Keywords = "2024, annual, financial";

pdf.ToPdfA();
pdf.SaveAs("annual-report-2024-pdfa.pdf");
Enter fullscreen mode Exit fullscreen mode

Metadata improves searchability in document management systems.

What Are Alternatives to IronPDF?

GhostScript: Free command-line tool. Requires shell execution from C#.

Aspose.PDF: Commercial library similar to IronPDF. More expensive licensing.

Syncfusion PDF: Another commercial option with PDF/A support.

I chose IronPDF for its simple API (ToPdfA() one-liner) and reliable conversion quality across diverse input PDFs.


Written by Jacob Mellor, CTO at Iron Software. Jacob created IronPDF and leads a team of 50+ engineers building .NET document processing libraries.

Top comments (0)