Skip to content
Snippets Groups Projects
Commit 96243190 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Prevent tracebacks when obtaining PDF metadata from files with multiple PDF...

Prevent tracebacks when obtaining PDF metadata from files with multiple PDF dictionary definition entries. (Closes: #913315)
parent cf3bc340
No related branches found
No related tags found
No related merge requests found
Pipeline #24697 passed
......@@ -63,11 +63,12 @@ class PdfFile(File):
def dump_pypdf2_metadata(file):
try:
pdf = PyPDF2.PdfFileReader(file.path)
document_info = pdf.getDocumentInfo()
except PyPDF2.utils.PdfReadError as exc:
return "(Could not extract metadata: {})".format(exc)
xs = []
for k, v in sorted(pdf.getDocumentInfo().items()):
for k, v in sorted(document_info.items()):
xs.append("{}: {!r}".format(k.lstrip('/'), v))
return "\n".join(xs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment