Updating PDF metadata

Hi,

I have just started learning Rust and am part way through my first project. I want to be able to update the metadata (title, author, subject, keywords) associated with PDF files. Can anyone advise which (if any) crate might support that?

Thanks

I've used https://crates.io/crates/lopdf for creating PDFs. In theory you can load your PDF, iterate through it and replace values. You may need those values:

You find it in the spec https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf page 550.

I wish you good luck :slight_smile:, PDF is such a mess, but it's doable.

Regards
Philipp

1 Like

Thanks @daaitch. I'll have a look and see what sense I can make of it!

Looking in the spec you referenced, section 14.3.2, it states:

Metadata, both for an entire document and for components within a document, may be stored in PDF streams called metadata streams (PDF 1.4).
:
The contents of a metadata stream shall be the metadata represented in Extensible Markup Language (XML).
:
The format of the XML representing the metadata is defined as part of a framework called the Extensible Metadata Platform (XMP) and described in the Adobe document XMP: Extensible Metadata Platform.

Digging around a bit further, I discovered:
xmp_toolkit, and
xmp-writer

Hopefully, one of those will further help me in my quest!