Skip to content

Commit

Permalink
Merge pull request #119 from maxpmaxp/issue-62-unbalanced-bt-et
Browse files Browse the repository at this point in the history
ISSUE-62: work around unbalanced BT/ET
  • Loading branch information
maxpmaxp authored Apr 30, 2024
2 parents 4f47d43 + cc2f992 commit 48044e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions pdfreader/viewer/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 48044e5

Please sign in to comment.