Embed an ICC color profile as the /OutputIntent to satisfy the PDF/A requirement for a declared color space.
use pdfluent::{Document, pdfa::OutputIntent};
fn main() -> pdfluent::Result<()> {
let mut doc = Document::open("input.pdf")?;
// Use the built-in sRGB IEC61966-2.1 profile
let intent = OutputIntent::srgb();
doc.set_output_intent(intent)?;
doc.save("with_output_intent.pdf")?;
Ok(())
}The output intent is a document-level property, not page-level. Open with mutable access.
let mut doc = Document::open("input.pdf")?;PDFluent ships sRGB IEC61966-2.1 and ISO Coated v2 (FOGRA39) profiles. These cover the vast majority of PDF/A archiving requirements.
use pdfluent::pdfa::OutputIntent;
// For screen/web documents:
let srgb = OutputIntent::srgb();
// For print/CMYK documents:
let fogra39 = OutputIntent::iso_coated_v2();If you have a specific ICC profile file, load the bytes and construct an OutputIntent from them.
let icc_bytes = std::fs::read("custom_profile.icc")?;
let intent = OutputIntent::from_icc_bytes(
&icc_bytes,
"Custom CMYK Profile", // OutputConditionIdentifier
"GTS_PDFA1", // S (subtype)
)?;set_output_intent replaces any existing output intent. A PDF/A document must have exactly one.
doc.set_output_intent(intent)?;Re-validate to confirm the output intent requirement is now satisfied.
let report = doc.validate_pdf_a()?;
let output_intent_errors: Vec<_> = report
.errors()
.filter(|e| e.rule_id().starts_with("6.2"))
.collect();
println!("Output intent errors: {}", output_intent_errors.len());
doc.save("with_output_intent.pdf")?;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.