Create annotation object string for a passed-in link.
(lnk, xref_dst, pno_src, ctm)
| 1507 | # internal function to create the actual "/Annots" object string |
| 1508 | # -------------------------------------------------------------------------- |
| 1509 | def cre_annot(lnk, xref_dst, pno_src, ctm): |
| 1510 | """Create annotation object string for a passed-in link.""" |
| 1511 | |
| 1512 | r = lnk["from"] * ctm # rect in PDF coordinates |
| 1513 | rect = "%g %g %g %g" % tuple(r) |
| 1514 | if lnk["kind"] == LINK_GOTO: |
| 1515 | txt = annot_skel["goto1"] # annot_goto |
| 1516 | idx = pno_src.index(lnk["page"]) |
| 1517 | p = lnk["to"] * ctm # target point in PDF coordinates |
| 1518 | annot = txt % (xref_dst[idx], p.x, p.y, lnk["zoom"], rect) |
| 1519 | |
| 1520 | elif lnk["kind"] == LINK_GOTOR: |
| 1521 | if lnk["page"] >= 0: |
| 1522 | txt = annot_skel["gotor1"] # annot_gotor |
| 1523 | pnt = lnk.get("to", Point(0, 0)) # destination point |
| 1524 | if type(pnt) is not Point: |
| 1525 | pnt = Point(0, 0) |
| 1526 | annot = txt % ( |
| 1527 | lnk["page"], |
| 1528 | pnt.x, |
| 1529 | pnt.y, |
| 1530 | lnk["zoom"], |
| 1531 | lnk["file"], |
| 1532 | lnk["file"], |
| 1533 | rect, |
| 1534 | ) |
| 1535 | else: |
| 1536 | txt = annot_skel["gotor2"] # annot_gotor_n |
| 1537 | to = get_pdf_str(lnk["to"]) |
| 1538 | to = to[1:-1] |
| 1539 | f = lnk["file"] |
| 1540 | annot = txt % (to, f, rect) |
| 1541 | |
| 1542 | elif lnk["kind"] == LINK_LAUNCH: |
| 1543 | txt = annot_skel["launch"] # annot_launch |
| 1544 | annot = txt % (lnk["file"], lnk["file"], rect) |
| 1545 | |
| 1546 | elif lnk["kind"] == LINK_URI: |
| 1547 | txt = annot_skel["uri"] # annot_uri |
| 1548 | annot = txt % (lnk["uri"], rect) |
| 1549 | |
| 1550 | else: |
| 1551 | annot = "" |
| 1552 | |
| 1553 | return annot |
| 1554 | |
| 1555 | # -------------------------------------------------------------------------- |
| 1556 |
no test coverage detected
searching dependent graphs…