Check whether a PDF meets PDF/A-1b, PDF/A-2b, or PDF/A-3b archiving requirements. Get a structured list of violations with page and object references.
use pdfluent::{PdfDocument, PdfALevel};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let doc = PdfDocument::open("archive_candidate.pdf")?;
let report = doc.validate_pdf_a(PdfALevel::PdfA2b)?;
if report.is_conformant {
println!("Conforms to PDF/A-2b");
} else {
for v in &report.violations {
println!("[{}] {}", v.rule_id, v.message);
}
}
Ok(())
}Open the document you want to validate. The validator reads the entire structure, so larger files take slightly longer.
use pdfluent::PdfDocument;
let doc = PdfDocument::open("archive_candidate.pdf")?;PDFluent supports PDF/A-1b, PDF/A-2b, and PDF/A-3b. Choose the level your archiving policy requires.
use pdfluent::PdfALevel;
// Options: PdfALevel::PdfA1b, PdfA2b, PdfA3b
let level = PdfALevel::PdfA2b;Call validate_pdf_a() with the level. It returns a ValidationReport.
let report = doc.validate_pdf_a(level)?;report.is_conformant is true when no violations were found. report.violations is a Vec<Violation> with details for each issue.
println!("Conformant: {}", report.is_conformant);
println!("Violations: {}", report.violations.len());
for v in &report.violations {
println!(
"Rule {} on page {:?}: {}",
v.rule_id, v.page, v.message
);
}In a CI pipeline, return exit code 1 when violations are found so the build fails automatically.
if !report.is_conformant {
eprintln!("{} violation(s) found", report.violations.len());
std::process::exit(1);
}No JVM, no runtime, no DLL dependencies. Ships as a single native binary or WASM module.
Rust's ownership model prevents buffer overflows and use-after-free. No segfaults in PDF parsing.
Same code runs server-side, in Docker, on AWS Lambda, on Cloudflare Workers, or in the browser via WASM.