Solutions

Build and extract PDF portfolios.

Create PDF portfolios containing embedded files. Extract attachments from existing documents. Handle PDF/A-3 with embedded XML invoices.

Not in the current release. This capability is not part of the published PDFluent SDK today. See the changelog for what ships now.

Code example

rust
use pdfluent::{Sdk, portfolio::{PortfolioOptions, EmbeddedFile}};

fn main() -> pdfluent::Result<()> {
    let sdk = Sdk::new()?;
    let mut doc = sdk.open("invoice.pdf")?;

    // Attach a ZUGFeRD XML file for PDF/A-3 e-invoicing
    let xml_bytes = std::fs::read("zugferd_invoice.xml")?;

    let attachment = EmbeddedFile::builder()
        .name("ZUGFeRD-invoice.xml")
        .mime_type("application/xml")
        .description("ZUGFeRD 2.1 invoice data")
        .relationship(pdfluent::portfolio::Relationship::Alternative)
        .data(xml_bytes)
        .build();

    let opts = PortfolioOptions::builder()
        .add(PdfDocument::open(attachment)?)
        .conform_to_pdfa3b(true)
        .build();

    let output = doc.embed_files(opts)?;
    output.save("invoice_pdfa3.pdf")?;

    println!("Attachments: {}", output.attachment_count());
    Ok(())
}

Run cargo add [email protected] to get started.

What it does

Embedded file attachments

Attach any file type (XML, JSON, CSV, images, Office documents) to a PDF as an embedded file stream. Each attachment carries its name, MIME type, description, modification date, and a checksum stored in the file specification dictionary.

Portfolio creation

Build a PDF Portfolio (PDF 1.7 collection) with the Navigator layout. Each embedded file appears as a card in the portfolio view. Set display columns, sort order, and cover document. Compatible with Adobe Acrobat and other portfolio-aware viewers.

Attachment metadata

Set and read custom metadata on each attachment: description, creation date, modification date, MIME type, and relationship (Source, Alternative, Supplement, Unspecified). Metadata is stored in the EmbeddedFile stream dictionary per ISO 32000.

PDF/A-3 with embedded XML

Produce PDF/A-3b documents with embedded XML invoices conforming to ZUGFeRD 2.1 and Factur-X. The attachment relationship is set to Alternative, the file is listed in the AF array, and the document-level XMP metadata includes the required conformance declarations.

Attachment extraction

Extract all embedded files from any PDF in one call. Returns a Vec of attachment handles, each with its name, MIME type, and raw bytes. Useful for processing incoming PDF/A-3 invoices to extract the machine-readable XML.

Attachment enumeration

List all attachments in a document without extracting the data. Returns name, size, MIME type, and modification date for each file. Use this to check whether a PDF contains an embedded XML invoice before committing to a full extraction.

Deployment options

Server-side (Linux/macOS/Windows)AWS LambdaDockerKubernetesCloudflare Workers (WASM)

Frequently asked questions