Create, convert, and validate archival PDFs

A guide for developers using PDFluent to build accessible, standards-compliant PDFs that remain valid for decades.

Documents that stay valid for 50 years.

Long-term PDF archiving with PDFluent. Convert documents to PDF/A-1b, PDF/A-2b, and PDF/A-3b for compliance with ISO 19005 and EU archiving mandates.

rust
use pdfluent::{PdfDocument, PdfAProfile, CompressOptions};

fn main() -> pdfluent::Result<()> {
    let mut doc = PdfDocument::open("report.pdf")?;

    // Check PDF/A conformance for long-term archiving
    let report = doc.validate_pdfa(PdfAProfile::A2b)?;
    println!("PDF/A-2b compliant: {}", report.is_compliant());
    for v in &report.violations {
        println!("[{}] {}", v.rule, v.message);
    }

    // Subset fonts and compress for a smaller archival file
    doc.subset_fonts()?;
    doc.compress(CompressOptions::archival())?;
    doc.save("report-archival.pdf")?;
    Ok(())
}

Convert PDFs to archival PDF/A format.

Turn ordinary PDFs into ISO-compliant PDF/A-1b, PDF/A-2b, or PDF/A-3b files for long-term archiving. Embed fonts, fix color profiles, and attach files automatically.

rust
use pdfluent::{PdfDocument, compliance::PdfALevel};

fn convert_to_archival(input: &str, output: &str) -> anyhow::Result<()> {
    let mut doc = PdfDocument::open(input)?;

    // Convert to PDF/A-2b — auto-embeds fonts and attaches sRGB color profile
    let report = doc.convert_to_pdf_a(PdfALevel::A2b)?;

    if !report.warnings().is_empty() {
        for w in report.warnings() {
            eprintln!("Warning: {}", w);
        }
    }

    doc.save(output)?;
    println!("Saved PDF/A-2b to {output}");
    Ok(())
}

PDF/A validation. Zero false negatives.

Validate PDF/A conformance with zero false negatives. Full ISO 19005 support for PDF/A-1, 2, and 3 with detailed preflight reports.

rust
use pdfluent::{PdfDocument, PdfAProfile};

fn main() -> pdfluent::Result<()> {
    let doc = PdfDocument::open("archive.pdf")?;

    let report = doc.validate_pdfa(PdfAProfile::A2b)?;
    println!("Compliant: {}", report.is_compliant());
    println!("Violations: {}", report.violations.len());

    for v in &report.violations {
        println!("[{}] {} (page {:?})", v.rule, v.message, v.page);
    }
    Ok(())
}

Validate and enforce PDF compliance standards.

Check PDFs against PDF/A, PDF/UA, and PDF/X standards. Get machine-readable violation reports. Enforce standards in CI/CD pipelines and batch workflows.

rust
use pdfluent::{PdfDocument, PdfAProfile};

fn main() -> pdfluent::Result<()> {
    let doc = PdfDocument::open("document.pdf")?;

    let report = doc.validate_pdfa(PdfAProfile::A2b)?;
    if report.is_compliant() {
        println!("PDF/A-2b compliant");
    } else {
        for v in &report.violations {
            println!("[{}] {}", v.rule, v.message);
        }
    }
    Ok(())
}

Build accessible PDFs that meet PDF/UA-1.

Validate tag structure, alt text, reading order, and language declarations. Produce PDFs that pass screen readers and meet government accessibility mandates.

rust
use pdfluent::{PdfDocument, accessibility::{AltText, Standard, Validator}};

fn check_and_fix_accessibility(path: &str) -> anyhow::Result<()> {
    let mut doc = PdfDocument::open(path)?;

    // Validate against PDF/UA-1 (ISO 14289-1)
    let validator = Validator::new(Standard::PdfUa1);
    let report = validator.validate(&doc)?;

    println!("{} violation(s):", report.violations().len());
    for v in report.violations() {
        println!("  [{}] {}", v.clause(), v.message());
    }

    // Add alt text to untagged images
    for mut img in doc.images_without_alt_text() {
        img.set_alt_text(AltText::new("Decorative figure"))?;
    }

    doc.save(path)?;
    Ok(())
}