From cc2f992ec959993f3c66a8def81f8c19e246d0b9 Mon Sep 17 00:00:00 2001 From: Max Polshcha Date: Tue, 30 Apr 2024 09:33:22 -0400 Subject: [PATCH] work around unbalanced BT/ET --- CHANGELOG.txt | 1 + pdfreader/viewer/simple.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9a0590a..ed779fd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ pdfreader 0.1.15dev --------------------------- +- issue #62 - work around unbalanced BT/ET - reduced warnings logs noise - timezone issue in tests fixed - bitarray version bump to 2.9.2 diff --git a/pdfreader/viewer/simple.py b/pdfreader/viewer/simple.py index 64e932f..d30ac41 100644 --- a/pdfreader/viewer/simple.py +++ b/pdfreader/viewer/simple.py @@ -109,13 +109,15 @@ def on_inline_image(self, obj): def on_BT(self, op): if self.mode == "BT": - raise ValueError("BT operator without enclosing ET") + log.debug("BT operator without enclosing ET. Trying to recover.") + self.bracket_commands_stack.pop() self.bracket_commands_stack.append(op) def on_ET(self, op): if self.mode != "BT": - raise ValueError("ET operator without corresponding BT") - self.bracket_commands_stack.pop() + log.debug("ET operator without corresponding BT. Trying to recover.") + else: + self.bracket_commands_stack.pop() # Text handlers def on_Tf(self, op):