Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to add custom metadata? #256

Open
joseavegaa opened this issue Sep 20, 2021 · 2 comments
Open

[Question] How to add custom metadata? #256

joseavegaa opened this issue Sep 20, 2021 · 2 comments

Comments

@joseavegaa
Copy link

joseavegaa commented Sep 20, 2021

I've been trying to add custom metadata for it to be shown on the Custom Properties of Adobe Reader.

When using meta[o2s:name_of_property]: "value_of_property", I get an error saying that the key "o2s" doesn't exists. I've solved that by using it like meta["{http://ns.o2sol.com/schema/pdf/1.4/}name_of_property"] = "value_of_property", which generates the following in the XML part of the PDF.

<rdf:Description xmlns:ns0="http://ns.o2sol.com/schema/pdf/1.4/" rdf:about="" ns0:name_of_property="value_of_property"/></rdf:RDF>

It seems that Adobe Reader doesn't detect that as a custom metadata property and it's expecting something like:

<rdf:Description xmlns:o2s="http://ns.o2sol.com/schema/pdf/1.4/"> <o2s:name_of_property>value_of_property</o2s:name_of_property> </rdf:RDF>

How can I add custom metadata properties using pikepdf's open_metadata()?

Thanks for the help.

Versions:
pikepdf: 3.0.0
python: 3.9.7

@jbarlow83
Copy link
Member

Well, this is irritating. The two XML excerpts you presented are both equivalent as defined by the RDF schema.

The output pikepdf produces, inline RDF, is fully compliant with the relevant specs, but it seems Adobe Reader doesn't care. pikepdf does not generate nested RDF because it's more complex to generate. There is currently no way to ask to it.

I assume you mean that the custom properties don't appear in this dialog box, and do appear if formatted according to Reader's preferred format.
image

@jbarlow83
Copy link
Member

I checked that changing the format in which XMP metadata is generated from inline to structured does not cause new custom properties to appear in the dialog box shown above. I believe the issue may be that the dialog box above is showing DocumentInfo rather XMP. You'll have to explain where in Adobe Reader I can confirm that your custom values are being shown.

Otherwise, it appears to me that the way pikepdf generates metadata is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants