-
Notifications
You must be signed in to change notification settings - Fork 698
Open
Description
Description of the bug
On some sample PDF files, I get following IndexError, trying to get their links:
/usr/lib/python3.14/site-packages/pymupdf/__init__.py in ?(page)
11835 links = []
11836 while ln:
11837 nl = utils.getLinkDict(ln, page.parent)
11838 links.append(nl)
> 11839 ln = ln.next
11840 if links != [] and page.parent.is_pdf:
11841 linkxrefs = [x for x in
11842 #page.annot_xrefs()
/usr/lib/python3.14/site-packages/pymupdf/__init__.py in ?(self)
8588 if self.xref > 0: # prev link has an xref
8589 link_xrefs = [x[0] for x in self.parent.annot_xrefs() if x[1] == mupdf.PDF_ANNOT_LINK]
8590 link_ids = [x[2] for x in self.parent.annot_xrefs() if x[1] == mupdf.PDF_ANNOT_LINK]
8591 idx = link_xrefs.index(self.xref)
-> 8592 val.xref = link_xrefs[idx + 1]
8593 val.id = link_ids[idx + 1]
8594 else:
8595 val.xref = 0
IndexError: list index out of rangeHow to reproduce the bug
- Get sample file from here: https://github.com/ArtifexSoftware/tests/blob/master/pdf/Transparency-DesignGuide.pdf
- Run following python code:
document = pymupdf.Document("Transparency-DesignGuide.pdf")
page = document[0]
page.clip_to_rect(page.cropbox)
page.get_links()PyMuPDF version
1.27.1
Operating system
Linux
Python version
3.14
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels