Commit 96243190 authored by Chris Lamb's avatar Chris Lamb

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
Pipeline #24697 passed with stage
in 12 minutes and 19 seconds
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment