Set title, author, subject and keywords on any PDF via the MetadataMut builder. Changes are buffered until commit(), then flushed to the document.
use pdfluent::prelude::*;
fn main() -> Result<()> {
let mut doc = PdfDocument::open("report.pdf")?;
doc.metadata_mut()
.set_title("Q3 Financial Report")
.set_author("Finance Team")
.set_subject("Quarterly earnings, consolidated")
.set_keywords(&["finance", "q3", "2026"])
.commit()?;
doc.save("report_tagged.pdf")?;
Ok(())
}Open with a mutable binding. MetadataMut borrows &mut on the document for the duration of the builder chain.
use pdfluent::prelude::*;
let mut doc = PdfDocument::open("report.pdf")?;metadata_mut() returns a MetadataMut builder. Each setter returns &mut Self so you can chain them. Changes are buffered locally — nothing is written until commit().
let mut meta = doc.metadata_mut();
meta.set_title("Q3 Financial Report")
.set_author("Finance Team")
.set_subject("Quarterly earnings")
.set_keywords(&["finance", "q3", "2026"]);commit() writes the buffered changes to the Info dictionary. It returns Result<()>; call it explicitly so you can handle write errors. MetadataMut also flushes on drop, but in that path errors are silenced.
doc.metadata_mut()
.set_title("Q3 Financial Report")
.set_author("Finance Team")
.commit()?;save() writes the PDF to disk. The metadata changes are part of that write; no separate flush step required.
doc.save("report_tagged.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.