Skip to main content

Crate pdf_compliance

Crate pdf_compliance 

Source
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

TypeDescription
PdfALevelPDF/A conformance level: A1b, A2b, A2u, A3b, A4, …
PdfXLevelPDF/X level: X1a2003, X32003, X4
ComplianceReportValidation outcome with issue list and pass/fail flag
ComplianceIssueRule ID, severity, message, and optional location
SeverityError, Warning, Info

Modules§

tagged
Tagged PDF: structure tree parsing, reading order, alt text extraction.

Structs§

ComplianceIssue
A single compliance issue found during checking.
ComplianceReport
A complete compliance report.

Enums§

PdfALevel
PDF/A conformance level (ISO 19005 parts 1–4).
PdfXLevel
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_pdfa but prints per-check timing to stderr.
validate_pdfa_with_progress
Like validate_pdfa but 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.