Expand description
PDF compliance checking: PDF/A, PDF/UA, and PDF/X.
Validates PDF documents against conformance profiles defined by:
- ISO 19005 — PDF/A archival format (parts 1–4)
- ISO 14289 — PDF/UA accessibility
- ISO 15930 — PDF/X prepress exchange
§Quick Start
use std::sync::Arc;
use pdf_syntax::Pdf;
use pdf_compliance::{preferred_pdfa_level, validate_pdfa, Severity};
let data = Arc::new(std::fs::read("document.pdf").unwrap());
let pdf = Pdf::new(data).unwrap();
// Prefer the declared level, but promote PDF/A-1 inputs to PDF/A-2B when
// the source uses features like xref streams, transparency, or JPEG2000.
let level = preferred_pdfa_level(&pdf);
let report = validate_pdfa(&pdf, level);
if report.is_compliant() {
println!("PDF/A-{}{} compliant", level.part(), level.conformance());
} else {
println!("{} error(s), {} warning(s)", report.error_count(), report.warning_count());
for issue in &report.issues {
if issue.severity == Severity::Error {
println!(" [{}] {:?}: {}", issue.rule, issue.severity, issue.message);
}
}
}§Key Types
| Type | Description |
|---|---|
PdfALevel | PDF/A conformance level: A1b, A2b, A2u, A3b, A4, … |
PdfXLevel | PDF/X level: X1a2003, X32003, X4 |
ComplianceReport | Validation outcome with issue list and pass/fail flag |
ComplianceIssue | Rule ID, severity, message, and optional location |
Severity | Error, Warning, Info |
Modules§
- tagged
- Tagged PDF: structure tree parsing, reading order, alt text extraction.
Structs§
- Compliance
Issue - A single compliance issue found during checking.
- Compliance
Report - A complete compliance report.
Enums§
- PdfA
Level - PDF/A conformance level (ISO 19005 parts 1–4).
- PdfX
Level - PDF/X conformance level (ISO 15930).
- Severity
- Severity of a compliance issue.
Functions§
- detect_
pdfa_ level - Detect the PDF/A level declared in XMP metadata.
- parse_
structure_ tree - Parse the structure tree from a PDF.
- preferred_
pdfa_ level - Choose the preferred PDF/A level for validating or converting a source PDF.
- validate_
pdfa - Validate a PDF against a PDF/A conformance level.
- validate_
pdfa_ timed - Like
validate_pdfabut prints per-check timing to stderr. - validate_
pdfa_ with_ progress - Like
validate_pdfabut updates a progress tracker with the name of the current check. Useful for diagnosing timeouts — the caller can read the tracker to see which check was last running. - validate_
pdfua - Validate a PDF against PDF/UA-1 (ISO 14289-1).
- validate_
pdfx - Validate a PDF against a PDF/X conformance level.