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

Method insert_textbox

src/__init__.py:12612–12682  ·  view source on GitHub ↗

Insert text into a given rectangle. Notes: Creates a Shape object, uses its same-named method and commits it. Parameters: rect: (rect-like) area to use for text. buffer: text to be inserted fontname: a Base-14 font, font name or '/name

(
            page: 'Page',
            rect: rect_like,
            buffer: typing.Union[str, list],
            *,
            fontname: str = "helv",
            fontfile: OptStr = None,
            set_simple: int = 0,
            encoding: int = 0,
            fontsize: float = 11,
            lineheight: OptFloat = None,
            color: OptSeq = None,
            fill: OptSeq = None,
            expandtabs: int = 1,
            align: int = 0,
            rotate: int = 0,
            render_mode: int = 0,
            miter_limit: float = 1,
            border_width: float = 0.05,
            morph: OptSeq = None,
            overlay: bool = True,
            stroke_opacity: float = 1,
            fill_opacity: float = 1,
            oc: int = 0,
            )

Source from the content-addressed store, hash-verified

12610 return rc
12611
12612 def insert_textbox(
12613 page: 'Page',
12614 rect: rect_like,
12615 buffer: typing.Union[str, list],
12616 *,
12617 fontname: str = "helv",
12618 fontfile: OptStr = None,
12619 set_simple: int = 0,
12620 encoding: int = 0,
12621 fontsize: float = 11,
12622 lineheight: OptFloat = None,
12623 color: OptSeq = None,
12624 fill: OptSeq = None,
12625 expandtabs: int = 1,
12626 align: int = 0,
12627 rotate: int = 0,
12628 render_mode: int = 0,
12629 miter_limit: float = 1,
12630 border_width: float = 0.05,
12631 morph: OptSeq = None,
12632 overlay: bool = True,
12633 stroke_opacity: float = 1,
12634 fill_opacity: float = 1,
12635 oc: int = 0,
12636 ) -> float:
12637 """Insert text into a given rectangle.
12638
12639 Notes:
12640 Creates a Shape object, uses its same-named method and commits it.
12641 Parameters:
12642 rect: (rect-like) area to use for text.
12643 buffer: text to be inserted
12644 fontname: a Base-14 font, font name or '/name'
12645 fontfile: name of a font file
12646 fontsize: font size
12647 lineheight: overwrite the font property
12648 color: RGB color triple
12649 expandtabs: handles tabulators with string function
12650 align: left, center, right, justified
12651 rotate: 0, 90, 180, or 270 degrees
12652 morph: morph box with a matrix and a fixpoint
12653 overlay: put text in foreground or background
12654 Returns:
12655 unused or deficit rectangle area (float)
12656 """
12657 img = page.new_shape()
12658 rc = img.insert_textbox(
12659 rect,
12660 buffer,
12661 fontsize=fontsize,
12662 lineheight=lineheight,
12663 fontname=fontname,
12664 fontfile=fontfile,
12665 set_simple=set_simple,
12666 encoding=encoding,
12667 color=color,
12668 fill=fill,
12669 expandtabs=expandtabs,

Callers 8

apply_redactionsMethod · 0.45
test_2812Function · 0.45
test_3148Function · 0.45
test_textbox2Function · 0.45
test_textbox5Function · 0.45
test_2637Function · 0.45
new-annots.pyFile · 0.45

Calls 2

new_shapeMethod · 0.80
commitMethod · 0.45

Tested by 5

test_2812Function · 0.36
test_3148Function · 0.36
test_textbox2Function · 0.36
test_textbox5Function · 0.36
test_2637Function · 0.36