DOC: Update metadata.md to add example for custom field access #3443
Open
chiptemm wants to merge 1 commit intopy-pdf:mainfrom
Open
DOC: Update metadata.md to add example for custom field access #3443chiptemm wants to merge 1 commit intopy-pdf:mainfrom
chiptemm wants to merge 1 commit intopy-pdf:mainfrom
Conversation
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']
| 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) |
Collaborator
There was a problem hiding this comment.
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
readerover custom names and using double quotes. - What are "primitive analogs"? Why not just use the term property which Python developers should know already?
stefan6419846
requested changes
Nov 10, 2025
Collaborator
stefan6419846
left a comment
There was a problem hiding this comment.
Please see review comment. Additionally, please rebase on the latest changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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