Create annotation object string for a passed-in link.
(lnk, xref_dst, pno_src, ctm)
| 3146 | # internal function to create the actual "/Annots" object string |
| 3147 | # -------------------------------------------------------------------------- |
| 3148 | def cre_annot(lnk, xref_dst, pno_src, ctm): |
| 3149 | """Create annotation object string for a passed-in link.""" |
| 3150 | |
| 3151 | r = lnk["from"] * ctm # rect in PDF coordinates |
| 3152 | rect = _format_g(tuple(r)) |
| 3153 | if lnk["kind"] == LINK_GOTO: |
| 3154 | txt = annot_skel["goto1"] # annot_goto |
| 3155 | idx = pno_src.index(lnk["page"]) |
| 3156 | p = lnk["to"] * ctm # target point in PDF coordinates |
| 3157 | annot = txt(xref_dst[idx], p.x, p.y, lnk["zoom"], rect) |
| 3158 | |
| 3159 | elif lnk["kind"] == LINK_GOTOR: |
| 3160 | if lnk["page"] >= 0: |
| 3161 | txt = annot_skel["gotor1"] # annot_gotor |
| 3162 | pnt = lnk.get("to", Point(0, 0)) # destination point |
| 3163 | if type(pnt) is not Point: |
| 3164 | pnt = Point(0, 0) |
| 3165 | annot = txt( |
| 3166 | lnk["page"], |
| 3167 | pnt.x, |
| 3168 | pnt.y, |
| 3169 | lnk["zoom"], |
| 3170 | lnk["file"], |
| 3171 | lnk["file"], |
| 3172 | rect, |
| 3173 | ) |
| 3174 | else: |
| 3175 | txt = annot_skel["gotor2"] # annot_gotor_n |
| 3176 | to = get_pdf_str(lnk["to"]) |
| 3177 | to = to[1:-1] |
| 3178 | f = lnk["file"] |
| 3179 | annot = txt(to, f, rect) |
| 3180 | |
| 3181 | elif lnk["kind"] == LINK_LAUNCH: |
| 3182 | txt = annot_skel["launch"] # annot_launch |
| 3183 | annot = txt(lnk["file"], lnk["file"], rect) |
| 3184 | |
| 3185 | elif lnk["kind"] == LINK_URI: |
| 3186 | txt = annot_skel["uri"] # annot_uri |
| 3187 | annot = txt(lnk["uri"], rect) |
| 3188 | |
| 3189 | else: |
| 3190 | annot = "" |
| 3191 | |
| 3192 | return annot |
| 3193 | |
| 3194 | # -------------------------------------------------------------------------- |
| 3195 |
nothing calls this directly
no test coverage detected