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

Function test_textbox1

tests/test_textbox.py:25–41  ·  view source on GitHub ↗

Use TextWriter for text insertion.

()

Source from the content-addressed store, hash-verified

23# codespell:ignore-end
24
25def test_textbox1():
26 """Use TextWriter for text insertion."""
27 doc = pymupdf.open()
28 page = doc.new_page()
29 rect = pymupdf.Rect(50, 50, 400, 400)
30 blue = (0, 0, 1)
31 tw = pymupdf.TextWriter(page.rect, color=blue)
32 tw.fill_textbox(
33 rect,
34 text,
35 align=pymupdf.TEXT_ALIGN_LEFT,
36 fontsize=12,
37 )
38 tw.write_text(page, morph=(rect.tl, pymupdf.Matrix(1, 1)))
39 # check text containment
40 assert page.get_text() == page.get_text(clip=rect)
41 page.write_text(writers=tw)
42
43
44def test_textbox2():

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…