From 226b0d0e17e9dd51ccb094ffda4720fe7d803784 Mon Sep 17 00:00:00 2001 From: awwaawwa <8493196+awwaawwa@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:16:38 +0800 Subject: [PATCH] feat(pdfinterp): add on_new_stream call and method - call on_new_stream in pdfinterp.py to reset color spaces - implement on_new_stream in il_creater.py to reset stroking and non-stroking color space names --- yadt/document_il/frontend/il_creater.py | 4 ++++ yadt/pdfinterp.py | 1 + 2 files changed, 5 insertions(+) diff --git a/yadt/document_il/frontend/il_creater.py b/yadt/document_il/frontend/il_creater.py index a1e4147..ebc0891 100644 --- a/yadt/document_il/frontend/il_creater.py +++ b/yadt/document_il/frontend/il_creater.py @@ -29,6 +29,10 @@ def on_stroking_color_space(self, color_space_name): def on_non_stroking_color_space(self, color_space_name): self.non_stroking_color_space_name = color_space_name + def on_new_stream(self): + self.stroking_color_space_name = None + self.non_stroking_color_space_name = None + def on_page_start(self): self.current_page = il_version_1.Page( pdf_font=[], diff --git a/yadt/pdfinterp.py b/yadt/pdfinterp.py index c2340dd..fd1dcaf 100644 --- a/yadt/pdfinterp.py +++ b/yadt/pdfinterp.py @@ -348,6 +348,7 @@ def execute(self, streams: Sequence[object]) -> None: while True: try: (_, obj) = parser.nextobject() + self.il_creater.on_new_stream() except PSEOF: break if isinstance(obj, PSKeyword):