Skip to Content
NexPDF

PDF/A and PDF/UA validation

Validate the document shown in a .NET MAUI PdfView against PDF/A (every level from 1a to 4f) and PDF/UA-1 and -2 with clause ids, and convert it to a chosen PDF/A or PDF/UA level.

English

License module

Validation and conversion need the standards module (Enterprise tier).

NexPDF checks documents against the machine-checkable rules of PDF/A (ISO 19005-1 to -4) and PDF/UA (ISO 14289). Each failure names the clause of the standard that requires it, with the same numbers the veraPDF rule sets use.

Validate PDF/A

ValidatePdfaJson(level) takes 1a, 1b, 2a, 2b, 2u, 3a, 3b, 3u, 4, 4e or 4f (or PDF/A-2b); null uses the level the document declares, or 2b.

using System.Text.Json.Nodes;

var doc = view.Document!;
var report = JsonNode.Parse(await Task.Run(() => doc.ValidatePdfaJson("2b")))!;
StatusLabel.Text = report["compliant"]!.GetValue<bool>() ? "PDF/A-2b" : $"{report["failures"]!.AsArray().Count} problems";
foreach (var f in report["failures"]!.AsArray())
    System.Diagnostics.Debug.WriteLine($"{f!["clause"]} {f["message"]} page {f["page"]}");

Each failure has clause, message, page (1-based, or null) and object (or null).

Validate PDF/UA

ValidatePdfuaJson() validates against the PDF/UA part the document declares, PDF/UA-1 by default, with the same report shape and level PDF/UA-1 or PDF/UA-2. PDF/UA-2 validation is complete: PDF 2.0 namespaces, the ISO 14289-2 rules and the ISO/TS 32005 parent and child rules. ValidatePdfuaPartJson(part) validates against part 1 or 2 whatever the document declares.

Convert to a level

ConvertPdfaLevel(level) converts to the level you choose (null is 2b) and returns 1 when the result validates. When some clauses still fail, the fixes that could be made are kept and the call throws NexPdfException listing the clauses left:

try
{
    await Task.Run(() => doc.ConvertPdfaLevel("3b"));
}
catch (NexPdfException e)
{
    System.Diagnostics.Debug.WriteLine($"still failing: {e.Message}");
}
doc.Save(Path.Combine(FileSystem.AppDataDirectory, "archive-pdfa3b.pdf"));

Convert with a report

ConvertPdfaJson(level, flattenDpi, substituteFonts) converts without throwing and reports level, compliant, fixed, substitutions and the clauses still remaining. ConvertPdfuaJson(part, lang) tags, embeds fonts and converts to PDF/UA-1 or PDF/UA-2:

var pdfa = JsonNode.Parse(await Task.Run(() => doc.ConvertPdfaJson("2b", 300, 1)))!;
var ua = JsonNode.Parse(await Task.Run(() => doc.ConvertPdfuaJson(2, "pt-PT")))!;
System.Diagnostics.Debug.WriteLine($"{pdfa["compliant"]} {ua["profile"]} {ua["compliant"]}");
await view.ReloadAsync();

PDF/A conversion flattens PDF/A-1 transparency (flattenDpi, 0 is 300), fixes device colour, draws missing appearance streams and substitutes metric-compatible fonts for non-embedded fonts (substituteFonts 0 leaves them alone). NexPdfSdk.RegisterSubstituteFont(data) adds a TrueType font of your own for substitution. Run OCR before converting a file that must be PDF/A.

See PDF/A, PDF/X and PDF/UA and the .NET validation guide for what the rules cover.

On this page