Validate PDF/UA conformance
PDF/UA validation checks whether a PDF meets the accessibility requirements of ISO 14289-1. Use this workflow after generating accessible PDFs or before accepting uploaded documents into an accessibility compliance process.
Nutrient .NET SDK validates PDF/UA-1 documents in process. The validator returns a Boolean result and an XML report that describes validation details.
Download samplePreparing the project
Register the SDK license before running validation operations. PDF/UA validation requires a license with the PDF/UA validation feature. For setup details, refer to the getting started with .NET SDK guide.
using System;using System.IO;using GdPicture14;
LicenseManager license = new LicenseManager();license.RegisterKEY(""); // Set your license keyLoading the PDF document
Create a GdPicturePDF instance and load the source file:
using GdPicturePDF pdf = new GdPicturePDF();GdPictureStatus status = pdf.LoadFromFile(@"input.pdf", false);
if (status != GdPictureStatus.OK){ throw new InvalidOperationException($"The PDF couldn't be loaded. Status: {status}");}The second argument controls whether the document is loaded into memory (LoadInMemory). Set it to true to load in memory (required if you plan to overwrite the source file), or false to read it from disk.
Validating PDF/UA conformance
Run PDF/UA-1 validation and write the detailed XML report to a file:
string validationReport = "";bool isValid = pdf.CheckPDFUAConformance(PdfValidationConformance.PDF_UA_1, ref validationReport);GdPictureStatus validationStatus = pdf.GetStat();
if (validationStatus != GdPictureStatus.OK){ throw new InvalidOperationException($"PDF/UA validation failed. Status: {validationStatus}");}
File.WriteAllText(@"validation-report.xml", validationReport);Console.WriteLine(isValid ? "The document is PDF/UA-1 compliant." : "The document isn't PDF/UA-1 compliant.");CheckPDFUAConformance validates the document against the requested conformance level. The Boolean result reports whether the document passed validation. The XML report provides details for audit, troubleshooting, or human review workflows.
For a basic pass-or-fail check, use IsValidPDFUA. It validates PDF/UA conformance and also supports returning the XML report:
string quickValidationReport = "";bool quickResult = pdf.IsValidPDFUA(ref quickValidationReport);Checking declared PDF conformance
To read the conformance declared by the loaded PDF, use GetPDFConformance:
PdfConformance declaredConformance = pdf.GetPDFConformance();Console.WriteLine($"Declared conformance: {declaredConformance}");GetPDFConformance replaces GetPDFAConformance. GetPDFAConformance is retained for backward compatibility. Use GetPDFConformance for new code because it reports both PDF/A and PDF/UA conformance.
Handling validation results
In production, use the validation result to route the document:
- Accept the document when
isValidistrue. - Store the XML report with the document for audit trails.
- Send failed documents to a remediation workflow.
- Log
GdPictureStatusvalues when loading or validation fails.
Conclusion
This workflow validates a PDF against PDF/UA-1, writes a detailed XML report, and reads the PDF conformance declared by the document.
For PDF/UA generation, refer to the PDF to PDF/UA guide.