Skip to content

Conversation

chiptemm
Copy link

Adding a part to Writing Metadata section to explain that custom metadata fields added this way need to be accessed using their string literal name because they do not have primitive names.

works: reader.metadata['/CustomField']
not works: reader.metadata.CustomField or reader.metadata.customfield

Adding a part to "Writing Metadata" section to explain that custom metadata fields added this way need to be accessed using their string literal name because they do not have primitive names.  Like reader.metadata['/CustomField']
@@ -60,6 +60,10 @@ writer.add_metadata(
# Save the new PDF to a file
with open("meta-pdf.pdf", "wb") as f:
writer.write(f)

#Access new custom field (while standard fields like Author have primitive analogs and can be accessed like reader.metadata.author, custom fields do not)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I would have thought that this is obvious, but apparently it is not?

Regarding the changes itself:

  • Please keep a consistent style, id est starting comments with a whitespace, using reader over custom names and using double quotes.
  • What are "primitive analogs"? Why not just use the term property which Python developers should know already?

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

Successfully merging this pull request may close these issues.

2 participants