Check self.cur_item._objs length before [-1]

In theory shouldn't happen, but came across a malformed PDF that threw
an error here; simple enough check that seemed worth adding.
This commit is contained in:
Jeremy Singer-Vine
2024-02-10 18:31:17 -05:00
parent f73fbe1c6c
commit 4f39d0364d
+4 -3
View File
@@ -147,9 +147,10 @@ class PDFPageAggregatorWithMarkedContent(PDFPageAggregator):
# create one object, but that is far from being guaranteed.
# Even if pdfminer.six's API would just return the objects it
# creates, we wouldn't have to do this.
cur_obj = self.cur_item._objs[-1]
cur_obj.mcid = self.cur_mcid # type: ignore
cur_obj.tag = self.cur_tag # type: ignore
if self.cur_item._objs:
cur_obj = self.cur_item._objs[-1]
cur_obj.mcid = self.cur_mcid # type: ignore
cur_obj.tag = self.cur_tag # type: ignore
def render_char(self, *args, **kwargs) -> float: # type: ignore
"""Hook for rendering characters, adding the `mcid` attribute."""