MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / insert_textbox

Function insert_textbox

src_classic/utils.py:1727–1794  ·  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' fontfile: 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,
    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

1725
1726
1727def insert_textbox(
1728 page: Page,
1729 rect: rect_like,
1730 buffer: typing.Union[str, list],
1731 fontname: str = "helv",
1732 fontfile: OptStr = None,
1733 set_simple: int = 0,
1734 encoding: int = 0,
1735 fontsize: float = 11,
1736 lineheight: OptFloat = None,
1737 color: OptSeq = None,
1738 fill: OptSeq = None,
1739 expandtabs: int = 1,
1740 align: int = 0,
1741 rotate: int = 0,
1742 render_mode: int = 0,
1743 border_width: float = 0.05,
1744 morph: OptSeq = None,
1745 overlay: bool = True,
1746 stroke_opacity: float = 1,
1747 fill_opacity: float = 1,
1748 oc: int = 0,
1749) -> float:
1750 """Insert text into a given rectangle.
1751
1752 Notes:
1753 Creates a Shape object, uses its same-named method and commits it.
1754 Parameters:
1755 rect: (rect-like) area to use for text.
1756 buffer: text to be inserted
1757 fontname: a Base-14 font, font name or '/name'
1758 fontfile: name of a font file
1759 fontsize: font size
1760 lineheight: overwrite the font property
1761 color: RGB color triple
1762 expandtabs: handles tabulators with string function
1763 align: left, center, right, justified
1764 rotate: 0, 90, 180, or 270 degrees
1765 morph: morph box with a matrix and a fixpoint
1766 overlay: put text in foreground or background
1767 Returns:
1768 unused or deficit rectangle area (float)
1769 """
1770 img = page.new_shape()
1771 rc = img.insert_textbox(
1772 rect,
1773 buffer,
1774 fontsize=fontsize,
1775 lineheight=lineheight,
1776 fontname=fontname,
1777 fontfile=fontfile,
1778 set_simple=set_simple,
1779 encoding=encoding,
1780 color=color,
1781 fill=fill,
1782 expandtabs=expandtabs,
1783 render_mode=render_mode,
1784 border_width=border_width,

Callers

nothing calls this directly

Calls 3

new_shapeMethod · 0.80
insert_textboxMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…