From 72442fa3d01027313679eaab3839e09254e462e0 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 18 Feb 2022 23:35:44 -0800 Subject: [PATCH] Fix error messages when run with pikepdf 5.0.0 Appears that these are spurious errors from qpdf probing the /DecodeParms dict on images that don't have it. Not sure exactly why it happens but this can be safely ignored. --- src/ocrmypdf/helpers.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/helpers.py b/src/ocrmypdf/helpers.py index a0a08a52..2169e64a 100644 --- a/src/ocrmypdf/helpers.py +++ b/src/ocrmypdf/helpers.py @@ -220,11 +220,19 @@ def check_pdf(input_file: Path) -> bool: else: with pdf: messages = pdf.check() + success = True for msg in messages: if 'error' in msg.lower(): log.error(msg) + success = False + elif ( + "/DecodeParms: operation for dictionary attempted on object " + "of type null" in msg + ): + pass # Ignore/spurious warning else: log.warning(msg) + success = False sio = StringIO() linearize_msgs = '' @@ -239,7 +247,7 @@ def check_pdf(input_file: Path) -> bool: if linearize_msgs: log.warning(linearize_msgs) - if not messages and not linearize_msgs: + if success and not linearize_msgs: return True return False