From b0ce7c63dd27257d9c979fde9013243b8ae38c98 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 10 May 2018 16:09:43 -0700 Subject: [PATCH] Since PyMuPDF 1.13.3 corrupts text, pin 1.12.5 and work around it --- setup.py | 2 +- src/ocrmypdf/pdfinfo.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ab634951..ccb85522 100644 --- a/setup.py +++ b/setup.py @@ -251,7 +251,7 @@ setup( 'ruffus == 2.6.3', # pinned - ocrmypdf implements a 2.6.3 workaround ], extras_require={ - 'fitz': ['PyMuPDF >= 1.13.3'], + 'fitz': ['PyMuPDF == 1.12.5'], }, tests_require=tests_require, entry_points={ diff --git a/src/ocrmypdf/pdfinfo.py b/src/ocrmypdf/pdfinfo.py index 9aa32618..80bd8135 100644 --- a/src/ocrmypdf/pdfinfo.py +++ b/src/ocrmypdf/pdfinfo.py @@ -586,7 +586,12 @@ def _page_has_text(infile, pageno): "Smarter text detection that ignores text in margins" doc = fitz.Document(infile) - text = doc[pageno].getText('dict') + if fitz.version[0] >= '1.13.0': + text = doc[pageno].getText('dict') + else: + import json + textjson = doc[pageno].getText('json') + text = json.loads(textjson) if not text: return