Commit 9368a860 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fix a bug in PDFDocument.getContentInformation.

that raises an Exception for PDF documents without any metadata.
parent 4bb64d8b
...@@ -277,7 +277,7 @@ class PDFDocument(Image): ...@@ -277,7 +277,7 @@ class PDFDocument(Image):
else: else:
try: try:
pdf_file = PdfFileReader(tmp) pdf_file = PdfFileReader(tmp)
for info_key, info_value in pdf_file.getDocumentInfo().iteritems(): for info_key, info_value in (pdf_file.getDocumentInfo() or {}).iteritems():
info_key = info_key.lstrip("/") info_key = info_key.lstrip("/")
if isinstance(info_value, unicode): if isinstance(info_value, unicode):
info_value = info_value.encode("utf-8") info_value = info_value.encode("utf-8")
......
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