From 28b4c9a5460ffc7a430d12731d9c0f7a9173373f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 30 Jul 2017 04:17:23 -0400 Subject: [PATCH] Add workaround for PDF with IndirectObject as the rotation value. GitHub #261. Signed-off-by: Roberto Rosario --- HISTORY.rst | 5 +++++ mayan/apps/converter/backends/python.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3a19cdf385..0e927ad899 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,3 +1,8 @@ +2.6.5 (2017-XX-XX) +================== +- Add workaround for PDF with IndirectObject as the + rotation value. GitHub #261. + 2.6.4 (2017-07-26) ================== - Add missing replacements of reverse to resolve_url. diff --git a/mayan/apps/converter/backends/python.py b/mayan/apps/converter/backends/python.py index b97d4b6d0c..e17de77906 100644 --- a/mayan/apps/converter/backends/python.py +++ b/mayan/apps/converter/backends/python.py @@ -92,7 +92,9 @@ class Python(ConverterBase): if self.mime_type == 'application/pdf': pdf = PyPDF2.PdfFileReader(self.file_object) try: - result = pdf.getPage(page_number - 1).get('/Rotate') + result = pdf.getPage(page_number - 1).get('/Rotate', 0) + if isinstance(result, PyPDF2.generic.IndirectObject): + result = result.getObject() except Exception as exception: self.file_object.seek(0) pdf = PyPDF2.PdfFileReader(self.file_object)