How-to guides/PDF/A & Archiving

Add an ICC color profile output intent to a PDF/A in Rust

Embed an ICC color profile as the /OutputIntent to satisfy the PDF/A requirement for a declared color space.

rust
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(())
}
Install:cargo add pdfluentDownload SDK →

Step by step

1

Open the document

The output intent is a document-level property, not page-level. Open with mutable access.

rust
let mut doc = Document::open("input.pdf")?;
2

Use a built-in profile

PDFluent ships sRGB IEC61966-2.1 and ISO Coated v2 (FOGRA39) profiles. These cover the vast majority of PDF/A archiving requirements.

rust
use pdfluent::pdfa::OutputIntent;

// For screen/web documents:
let srgb = OutputIntent::srgb();

// For print/CMYK documents:
let fogra39 = OutputIntent::iso_coated_v2();
3

Load a custom ICC profile

If you have a specific ICC profile file, load the bytes and construct an OutputIntent from them.

rust
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)
)?;
4

Attach the intent to the document

set_output_intent replaces any existing output intent. A PDF/A document must have exactly one.

rust
doc.set_output_intent(intent)?;
5

Verify with a validation run

Re-validate to confirm the output intent requirement is now satisfied.

rust
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")?;

Notes and tips

  • All PDF/A conformance levels (1b, 1a, 2b, 2a, 2u, 3b) require an OutputIntent that declares the color space.
  • sRGB is suitable for RGB-based documents. If pages contain CMYK colors, use a CMYK ICC profile (FOGRA39 for European print, SWOP for North America).
  • A document may have multiple output intents for different color spaces, but only one per output condition identifier.
  • The ICC profile data is compressed and embedded as a stream object. Typical sRGB profiles add about 3KB to the file size.

Why PDFluent for this

Pure Rust

No JVM, no runtime, no DLL dependencies. Ships as a single native binary or WASM module.

Memory safe

Rust's ownership model prevents buffer overflows and use-after-free. No segfaults in PDF parsing.

Runs anywhere

Same code runs server-side, in Docker, on AWS Lambda, on Cloudflare Workers, or in the browser via WASM.

Frequently asked questions