Skip to content

Update XMP metadata directly #3395

@stefan6419846

Description

@stefan6419846

Explanation

The XmpInformation class for holding XMP metadata is currently restricted to read data. To actually update the data, the user has to mess with the associated XML through rdf_root. This may lead to strange results as well when first accessing a value and then updating it, as on the first read access, the values will be cached internally.

Code Example

from pypdf import PdfReader, PdfWriter

writer = PdfWriter(clone_from="file.pdf")
metadata = writer.xmp_metadata
assert metadata is not None
print(metadata.dc_author)
metadata.dc_author = "Foo Bar"
print(metadata.dc_author)
writer.write("output.pdf")

Metadata

Metadata

Assignees

No one assigned

    Labels

    PdfWriterThe PdfWriter component is affectedis-featureA feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions