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

Function getLinkDict

src_classic/utils.py:955–999  ·  view source on GitHub ↗
(ln)

Source from the content-addressed store, hash-verified

953
954
955def getLinkDict(ln) -> dict:
956 nl = {"kind": ln.dest.kind, "xref": 0}
957 try:
958 nl["from"] = ln.rect
959 except:
960 pass
961 pnt = Point(0, 0)
962 if ln.dest.flags & LINK_FLAG_L_VALID:
963 pnt.x = ln.dest.lt.x
964 if ln.dest.flags & LINK_FLAG_T_VALID:
965 pnt.y = ln.dest.lt.y
966
967 if ln.dest.kind == LINK_URI:
968 nl["uri"] = ln.dest.uri
969
970 elif ln.dest.kind == LINK_GOTO:
971 nl["page"] = ln.dest.page
972 nl["to"] = pnt
973 if ln.dest.flags & LINK_FLAG_R_IS_ZOOM:
974 nl["zoom"] = ln.dest.rb.x
975 else:
976 nl["zoom"] = 0.0
977
978 elif ln.dest.kind == LINK_GOTOR:
979 nl["file"] = ln.dest.fileSpec.replace("\\", "/")
980 nl["page"] = ln.dest.page
981 if ln.dest.page < 0:
982 nl["to"] = ln.dest.dest
983 else:
984 nl["to"] = pnt
985 if ln.dest.flags & LINK_FLAG_R_IS_ZOOM:
986 nl["zoom"] = ln.dest.rb.x
987 else:
988 nl["zoom"] = 0.0
989
990 elif ln.dest.kind == LINK_LAUNCH:
991 nl["file"] = ln.dest.fileSpec.replace("\\", "/")
992
993 elif ln.dest.kind == LINK_NAMED:
994 nl["name"] = ln.dest.named
995
996 else:
997 nl["page"] = ln.dest.page
998
999 return nl
1000
1001
1002def get_links(page: Page) -> list:

Callers 2

get_linksFunction · 0.70
recurseFunction · 0.70

Calls 1

PointClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…