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

Method add_freetext_annot

src/__init__.py:10376–10422  ·  view source on GitHub ↗

Add a 'FreeText' annotation.

(
            self,
            rect: rect_like,
            text: str,
            *,
            fontsize: float =11,
            fontname: OptStr =None,
            text_color: OptSeq =None,
            fill_color: OptSeq =None,
            border_color: OptSeq =None,
            border_width: float =0,
            dashes: OptSeq =None,
            callout: OptSeq =None,
            line_end: int=mupdf.PDF_ANNOT_LE_OPEN_ARROW,
            opacity: float =1,
            align: int =0,
            rotate: int =0,
            richtext=False,
            style=None,
            )

Source from the content-addressed store, hash-verified

10374 return annot
10375
10376 def add_freetext_annot(
10377 self,
10378 rect: rect_like,
10379 text: str,
10380 *,
10381 fontsize: float =11,
10382 fontname: OptStr =None,
10383 text_color: OptSeq =None,
10384 fill_color: OptSeq =None,
10385 border_color: OptSeq =None,
10386 border_width: float =0,
10387 dashes: OptSeq =None,
10388 callout: OptSeq =None,
10389 line_end: int=mupdf.PDF_ANNOT_LE_OPEN_ARROW,
10390 opacity: float =1,
10391 align: int =0,
10392 rotate: int =0,
10393 richtext=False,
10394 style=None,
10395 ) -> Annot:
10396 """Add a 'FreeText' annotation."""
10397
10398 old_rotation = annot_preprocess(self)
10399 try:
10400 annot = self._add_freetext_annot(
10401 rect,
10402 text,
10403 fontsize=fontsize,
10404 fontname=fontname,
10405 text_color=text_color,
10406 fill_color=fill_color,
10407 border_color=border_color,
10408 border_width=border_width,
10409 dashes=dashes,
10410 callout=callout,
10411 line_end=line_end,
10412 opacity=opacity,
10413 align=align,
10414 rotate=rotate,
10415 richtext=richtext,
10416 style=style,
10417 )
10418 finally:
10419 if old_rotation != 0:
10420 self.set_rotation(old_rotation)
10421 annot_postprocess(self, annot)
10422 return annot
10423
10424 def add_highlight_annot(self, quads=None, start=None,
10425 stop=None, clip=None) -> Annot:

Callers 8

test_freetextFunction · 0.80
test_1645Function · 0.80
test_4254Function · 0.80
test_richtextFunction · 0.80
test_4447Function · 0.80
new-annots.pyFile · 0.80

Calls 4

_add_freetext_annotMethod · 0.95
set_rotationMethod · 0.95
annot_preprocessFunction · 0.85
annot_postprocessFunction · 0.85

Tested by 5

test_freetextFunction · 0.64
test_1645Function · 0.64
test_4254Function · 0.64
test_richtextFunction · 0.64
test_4447Function · 0.64