Text following a redaction must not change coordinates.
()
| 799 | |
| 800 | |
| 801 | def test_2957_1(): |
| 802 | """Text following a redaction must not change coordinates.""" |
| 803 | # test file with redactions |
| 804 | doc = pymupdf.open(os.path.join(scriptdir, "resources", "test_2957_1.pdf")) |
| 805 | page = doc[0] |
| 806 | # search for string that must not move by redactions |
| 807 | rects0 = page.search_for("6e9f73dfb4384a2b8af6ebba") |
| 808 | # sort rectangles vertically |
| 809 | rects0 = sorted(rects0, key=lambda r: r.y1) |
| 810 | assert len(rects0) == 2 # must be 2 redactions |
| 811 | page.apply_redactions() |
| 812 | |
| 813 | # reload page to finalize updates |
| 814 | page = doc.reload_page(page) |
| 815 | |
| 816 | # the two string must retain their positions (except rounding errors) |
| 817 | rects1 = page.search_for("6e9f73dfb4384a2b8af6ebba") |
| 818 | rects1 = sorted(rects1, key=lambda r: r.y1) |
| 819 | |
| 820 | assert page.first_annot is None # make sure annotations have disappeared |
| 821 | for i in range(2): |
| 822 | r0 = rects0[i].irect # take rounded rects |
| 823 | r1 = rects1[i].irect |
| 824 | assert r0 == r1 |
| 825 | |
| 826 | |
| 827 | def test_2957_2(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…