Docs / Guides
PDF/A compliance
PDF/A is the ISO standard for long-term archiving: a file must contain everything needed to display it the same way decades from now. SoftZenPdf creates PDF/A-2b files and checks files against PDF/A-2b rules.
What PDF/A-2b requires
PDF/A-2b (ISO 19005-2, level B) guarantees reliable visual reproduction. Among other rules: every font must be embedded, colours must be tied to an ICC output intent, the file must carry XMP metadata identifying it as PDF/A, and encryption, JavaScript and external content are forbidden.
Creating a PDF/A-2b document
Start from PdfDocument.CreateForPdfA() instead of new PdfDocument():
using SoftZenPdf;
var document = PdfDocument.CreateForPdfA();
document.Info.Title = "Annual report";
var font = TrueTypeFont.FromFile("NotoSans-Regular.ttf");
document.AddPage().Content.DrawText("Archived", 72, 770, font, 14);
document.Save("report-pdfa.pdf"); // throws PdfAException if a check fails
- The producer, creation date and modification date are set for you, and kept identical in the Info dictionary and XMP.
- An sRGB ICC output intent and PDF/A identification (part 2, conformance B) are added when saving.
Savevalidates the output first and throwsPdfAExceptionlisting every violation. SetValidateOnSave = falseto skip the check.
Guard rails while you build
A document in PDF/A mode refuses forbidden features as soon as you use them, with the rule that forbids them:
using SoftZenPdf;
var document = PdfDocument.CreateForPdfA();
try
{
document.Encrypt("user123", "owner456");
}
catch (InvalidOperationException ex)
{
Console.WriteLine(ex.Message); // PDF/A forbids encryption (ISO 19005-2 §6.1.3) …
}
- Standard 14 fonts (not embedded): use a
TrueTypeFont - Encryption
- Form fields, whose appearances use standard fonts (not supported in PDF/A mode yet)
- CMYK JPEG images, which would need a CMYK output intent
- Turning off XMP metadata
Checking existing files
PdfReader.ValidatePdfA2b runs the same checks on any PDF and cites the ISO 19005-2 clause of each violation:
using SoftZenPdf;
foreach (var file in new[] { "report-pdfa.pdf", "hello.pdf" })
{
var result = PdfReader.Open(file).ValidatePdfA2b();
Console.WriteLine($"{file}: {(result.IsCompliant ? "no violations found" : $"{result.Violations.Count} violation(s)")}");
foreach (var violation in result.Violations)
Console.WriteLine($" {violation}");
}
report-pdfa.pdf: no violations found
hello.pdf: 3 violation(s)
[6.6.2.1] The catalog must contain an XMP /Metadata stream.
[6.2.11.4.1] Page 1: font /F1 (Helvetica) is not embedded.
[6.2.4.3] DeviceRGB is used, so the document needs an RGB PDF/A output intent.
Verification status
SoftZenPdf's validator is a practical subset of ISO 19005-2, not a replacement for a full validator. A cross-check of SoftZenPdf's PDF/A output with veraPDF is still pending; until then, validate files that must be archived with veraPDF. Only PDF/A-2b is supported, not PDF/A-1, PDF/A-3 or the U and A conformance levels.
API: PdfDocument.CreateForPdfA, PdfAValidationResult, PdfAException.