You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pattern writer.add_metadata(reader.metadata) doesn't work as there can be indirect objects.
This is unfortunate and an unnecessary complexity for the user.
Code Example
fromPyPDF2importPdfReader, PdfWriterreader=PdfReader("example.pdf")
writer=PdfWriter()
# How I want to use itwriter.add_metadata(reader.metadata)
The text was updated successfully, but these errors were encountered:
I imagine something like this on top of the existing code:
defget_meta(reader: PdfReader) ->Dict[str, Any]:
meta_new= {}
forkey, valueinreader.metadata.items():
i=0# I'm not sure if there could be infinite loopswhileisinstance(value, IndirectObject) andi<3:
value=reader.metadata[key].get_object()
i+=1ifnotisinstance(value, IndirectObject):
meta_new[key] =valuereturnmeta_new
Explanation
The pattern
writer.add_metadata(reader.metadata)
doesn't work as there can be indirect objects.This is unfortunate and an unnecessary complexity for the user.
Code Example
The text was updated successfully, but these errors were encountered: