MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / get_links

Function get_links

src_classic/utils.py:1002–1022  ·  view source on GitHub ↗

Create a list of all links contained in a PDF page. Notes: see PyMuPDF ducmentation for details.

(page: Page)

Source from the content-addressed store, hash-verified

1000
1001
1002def get_links(page: Page) -> list:
1003 """Create a list of all links contained in a PDF page.
1004
1005 Notes:
1006 see PyMuPDF ducmentation for details.
1007 """
1008
1009 CheckParent(page)
1010 ln = page.first_link
1011 links = []
1012 while ln:
1013 nl = getLinkDict(ln)
1014 links.append(nl)
1015 ln = ln.next
1016 if links != [] and page.parent.is_pdf:
1017 linkxrefs = [x for x in page.annot_xrefs() if x[1] == PDF_ANNOT_LINK]
1018 if len(linkxrefs) == len(links):
1019 for i in range(len(linkxrefs)):
1020 links[i]["xref"] = linkxrefs[i][0]
1021 links[i]["id"] = linkxrefs[i][2]
1022 return links
1023
1024
1025def get_toc(

Callers

nothing calls this directly

Calls 4

CheckParentFunction · 0.85
annot_xrefsMethod · 0.80
getLinkDictFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…