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

Function test_textbox4

tests/test_textbox.py:87–105  ·  view source on GitHub ↗

Use TextWriter for text insertion.

()

Source from the content-addressed store, hash-verified

85
86
87def test_textbox4():
88 """Use TextWriter for text insertion."""
89 doc = pymupdf.open()
90 ocg = doc.add_ocg("ocg1")
91 page = doc.new_page()
92 rect = pymupdf.Rect(50, 50, 400, 600)
93 blue = (0, 0, 1)
94 tw = pymupdf.TextWriter(page.rect, color=blue)
95 tw.fill_textbox(
96 rect,
97 text,
98 align=pymupdf.TEXT_ALIGN_LEFT,
99 fontsize=12,
100 font=pymupdf.Font("cour"),
101 right_to_left=True,
102 )
103 tw.write_text(page, oc=ocg, morph=(rect.tl, pymupdf.Matrix(1, 1)))
104 # check text containment
105 assert page.get_text() == page.get_text(clip=rect)
106
107
108def test_textbox5():

Callers

nothing calls this directly

Calls 5

fill_textboxMethod · 0.95
write_textMethod · 0.95
add_ocgMethod · 0.80
new_pageMethod · 0.80
get_textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…