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

Function test_textbox3

tests/test_textbox.py:64–84  ·  view source on GitHub ↗

Use TextWriter for text insertion.

()

Source from the content-addressed store, hash-verified

62
63
64def test_textbox3():
65 """Use TextWriter for text insertion."""
66 doc = pymupdf.open()
67 page = doc.new_page()
68 font = pymupdf.Font("cjk")
69 rect = pymupdf.Rect(50, 50, 400, 400)
70 blue = (0, 0, 1)
71 tw = pymupdf.TextWriter(page.rect, color=blue)
72 tw.fill_textbox(
73 rect,
74 text,
75 align=pymupdf.TEXT_ALIGN_LEFT,
76 font=font,
77 fontsize=12,
78 right_to_left=True,
79 )
80 tw.write_text(page, morph=(rect.tl, pymupdf.Matrix(1, 1)))
81 # check text containment
82 assert page.get_text() == page.get_text(clip=rect)
83 doc.scrub()
84 doc.subset_fonts()
85
86
87def test_textbox4():

Callers

nothing calls this directly

Calls 6

fill_textboxMethod · 0.95
write_textMethod · 0.95
new_pageMethod · 0.80
scrubMethod · 0.80
subset_fontsMethod · 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…