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.
use pdfluent::{Document, compliance::PdfALevel};
fn convert_to_archival(input: &str, output: &str) -> anyhow::Result<()> {
let mut doc = Document::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(())
}Run cargo add pdfluent to get started.
Choose the archival level that matches your requirement. PDF/A-1b for maximum compatibility. PDF/A-2b for JPEG 2000 compression and optional content. PDF/A-3b for embedded attachments such as XML invoices.
PDFluent detects partially-embedded or unembedded fonts and embeds the full font program from the system font registry. Documents with missing fonts produce a warning so you can take action when automatic substitution is not possible.
RGB and CMYK color spaces are tagged with ICC output intents. An sRGB profile is attached by default for RGB documents. You can supply a custom ICC profile for print or brand-critical workflows.
PDF/A requires compliant XMP metadata with pdfaid:conformance and pdfaid:part. PDFluent writes correct XMP automatically and preserves existing Dublin Core metadata when present.
Electronic invoicing standards ZUGFeRD 2.x and Factur-X require PDF/A-3b with an embedded XML attachment. PDFluent produces the correct AFRelationship and MIME-type entries needed by invoice validators.
Every conversion returns a typed report listing auto-fixed issues, warnings for items that required approximation, and errors for any clause that could not be satisfied. Use it to decide whether to accept or reject output.