Access XMP metadata, document information dictionary, and custom properties. Batch update metadata across thousands of files.
use pdfluent::{Sdk, DocInfo};
fn main() -> pdfluent::Result<()> {
let sdk = Sdk::new()?;
let mut doc = sdk.open("input.pdf")?;
// Read existing metadata
let info = doc.doc_info();
println!("Title: {:?}", info.title());
println!("Author: {:?}", info.author());
// Write new metadata
doc.set_doc_info(
DocInfo::builder()
.title("Q1 2026 Financial Report")
.author("Finance Team")
.subject("Quarterly earnings")
.keywords("earnings, Q1, 2026")
.creator("ReportGen v3.1")
.build(),
)?;
doc.save("output.pdf")?;
Ok(())
}Run cargo add pdfluent@1.0.0-beta.5 to get started.
Read and write Title, Author, Subject, Keywords, Creator, Producer, CreationDate, and ModDate. All fields are optional strings. PDFluent parses both text string and UTF-16BE encodings.
Access the full XMP packet attached to the document catalog. Read any XMP property by namespace and local name. Write XMP using the XmpBuilder API which serializes valid XML.
Register your own namespace URI and prefix. Set custom properties under that namespace. Useful for embedding workflow identifiers, system IDs, or compliance tags that tools like Adobe Acrobat and Foxit also recognize.
Process a directory of PDFs with a single loop. Open, update, and save each file in under 10 ms per document for metadata-only changes. Combine with Rayon to parallelize across CPU cores.
Read metadata without fully loading the document content. PDFluent provides a lightweight open mode that parses only the cross-reference table and the catalog. Suitable for indexing thousands of files quickly.
PDF/A-1b and PDF/A-2b require that the XMP packet and the document info dictionary stay synchronized. PDFluent writes both in one call and sets the correct pdfaid namespace properties when targeting PDF/A output.