Use TextWriter for text insertion.
()
| 85 | |
| 86 | |
| 87 | def 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 | |
| 108 | def test_textbox5(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…