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
When calling Document.setMetadata, some keys that are not the in dictionary are written the PDF document with the literal string value none. I think they should just be ommitted.
I worked around this problem for now with this method (because I had to roll out my code to production yesterday):
# pymupdf inserts stuff like '/Author (none)' when the author is not provided.
# This is wrong. We'll file a bug, but let's first fix it here.
def fixup_pymupdf_metadata(doc):
# Access to the Info xref is not in the API, so let's dig for it.
trailer_lines = outdoc.PDFTrailer().split('\n')
for line in trailer_lines:
if ' /Info ' in line:
s = line.replace(' /Info ', '')
info_xref = s[:s.find(' ')]
info_xref = int(info_xref)
s = doc.xrefObject(info_xref)
new_s = ''
for infoline in s.split('\n'):
if re.match('^.*\/[A-Za-z]+ \(none\)$', infoline):
continue
new_s += infoline + '\n'
doc.updateObject(info_xref, new_s)
break
The text was updated successfully, but these errors were encountered:
Please provide all mandatory information!
Describe the bug (mandatory)
When calling
Document.setMetadata
, some keys that are not the in dictionary are written the PDF document with the literal string valuenone
. I think they should just be ommitted.To Reproduce (mandatory)
Workaround
I worked around this problem for now with this method (because I had to roll out my code to production yesterday):
The text was updated successfully, but these errors were encountered: