---
title: "Check a PDF for PDF/A save issues in C#"
url: https://recursiveai.org/onepdf/cookbook/check-pdf-a-without-converting/
description: "Check whether a PDF can be saved as PDF/A in C#. Report structural issues without changing or converting the file. Includes a runnable .NET example."
version: "1.25.1"
---

# Check a PDF for PDF/A save issues in C#

**OnePDF** is a free, open-source PDF library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OnePdf) · [GitHub](https://github.com/recursive-ai-oss/onepdf-csharp) · [Docs](https://recursiveai.org/onepdf/docs/) · [Download example (.zip)](https://recursiveai.org/onepdf/cookbook/check-pdf-a-without-converting/check-pdf-a-without-converting.zip)

PDF/A is the ISO [archival PDF format](https://www.loc.gov/preservation/digital/formats/fdd/fdd000318.shtml). Check `sample.pdf` from the example download, or use the path to any PDF.

```shell
dotnet add package RecursiveAI.OnePdf
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using System;
using OnePdf;
using var doc =
    PdfDocument.Open("sample.pdf");
var issues = doc.CheckPdfA();
Console.WriteLine(issues.Count);
```

Unzip [the example](https://recursiveai.org/onepdf/cookbook/check-pdf-a-without-converting/check-pdf-a-without-converting.zip), then `dotnet run`.

Prints the number of issues OnePDF found for PDF/A-2b (the default profile). It doesn’t prove conformance, even when the count is zero.

```text
3
```

## The full program

The download checks a one-page PDF that uses Helvetica without embedding it. It prints the clause, location and reason for each issue. Run `dotnet run -- report.pdf` to check a different file. If the document exceeds the parser’s object or content limits during the check, `CheckPdfA` throws `PdfLimitException` rather than returning a clean report.

```csharp
using System;
using OnePdf;

string path = args.Length == 0 ? "sample.pdf" : args[0];
using var doc = PdfDocument.Open(path);
var issues = doc.CheckPdfA();
Console.WriteLine($"PDF/A-2b: {issues.Count} issue(s) found");
foreach (var issue in issues)
{
    string where = issue.ObjectNumber < 0 ? "file" : $"object {issue.ObjectNumber}";
    Console.WriteLine($"{issue.Clause} ({where}): {issue.Message}");
}
```

```text
PDF/A-2b: 3 issue(s) found
6.1.3 (file): The trailer has no /ID.
6.2.11.4.1 (object 5): The font Helvetica is not embedded.
6.6.2.1 (file): The catalog has no /Metadata stream with /Type /Metadata and /Subtype /XML.
```

## Variations

**Check a different profile.** Replace `doc.CheckPdfA()` in the snippet at the top with this call to check PDF/A-3u instead:

```csharp
doc.CheckPdfA(new PdfAOptions
{
    Part = PdfAPart.Part3,
    Conformance = PdfAConformance.U
})
```

```text
3
```

**To see what would still block a PDF/A save after OnePDF’s automatic fixes, use `PreparePdfA`.** It makes changes in memory without writing a file. Run this as `Program.cs` on the same sample:

```csharp
using System;
using OnePdf;

using var doc = PdfDocument.Open("sample.pdf",
    new() { AllowEditing = true });
foreach (var issue in doc.PreparePdfA())
    Console.WriteLine(issue.Message);
```

```text
The font Helvetica is not embedded.
```

The count drops from 3 to 1: OnePDF adds the missing XMP metadata in memory and doesn’t flag the missing trailer ID because a full save writes one. The unembedded font is still a problem.

## Related recipes

- [Convert a PDF to PDF/A](https://recursiveai.org/onepdf/cookbook/convert-pdf-to-pdfa/)
- [Create a new PDF/A file](https://recursiveai.org/onepdf/cookbook/create-pdf-a/)
- [Embed missing fonts in an existing PDF](https://recursiveai.org/onepdf/cookbook/embed-missing-fonts/)

## The short answer

Call `PdfDocument.CheckPdfA()` to see which PDF/A-2b rules OnePDF can check and found the current file to break. It works on a read-only document and neither edits it nor writes a file. For a different profile, pass a `PdfAOptions` with the part and level you need. This is a structural check, not a guarantee that a PDF/A save will succeed or a prediction of what the separate converter can repair.

## How can I tell if a PDF is PDF/A?

The `.pdf` extension doesn’t distinguish an ordinary PDF from an archival PDF/A file. The `pdfaid:part` and `pdfaid:conformance` entries in the XMP metadata tell you what the file *claims*: part `2` and level `B` mean PDF/A-2b. A claim isn’t enough to establish compliance. A file can keep that metadata after an edit that breaks a rule. If a submission requires PDF/A, check the actual requirements of the requested profile, not just the label.

OnePDF’s [PDF/A documentation](https://recursiveai.org/onepdf/docs/pdfa/#what-it-is-and-is-not) says: “`CheckPdfA` verifies what is listed below and nothing else; a clean result does not prove conformance.” Treat a clean result as “no issues found by these checks,” not “approved for archiving.” For example, OnePDF doesn’t detect features that exist only in PDF 2.0.

## Should I use PDF or PDF/A?

Use the profile the archive or receiving system asks for. If you only need to share a document and there’s no archival requirement, there’s no reason to convert it just to change the format label. If PDF/A is required, a file that fails the read-only check isn’t necessarily unconvertible. The bundled sample is missing its XMP metadata and has an unembedded font. Preparing the file adds archival metadata in memory, but leaves the original font alone. A PDF/A save also makes those routine repairs and refuses to write if it still finds a violation. The separate converter can try a substitute for an unembedded font, but it can refuse inputs too, for example when the font can’t draw a character that the page uses.

Read the clause and the message together. A file-wide finding like missing metadata has `ObjectNumber` of `-1`. A finding about a specific font can name the PDF object that needs attention, even when it doesn’t name a page. For a batch of files, keep the profile and those details in the log. If the check throws because it couldn’t finish, report that separately from a file that was checked and had no issues.
