Skip to content

Commit 2838348

Browse files
tests/: added test_4415().
This checks further mupdf fix for unbalanced "q"/"Q" graphics operators, which addresses #4415.
1 parent 2c45b05 commit 2838348

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

tests/resources/test_4415.pdf

1.47 KB
Binary file not shown.
18 KB
Loading

tests/test_general.py

+15
Original file line numberDiff line numberDiff line change
@@ -1670,3 +1670,18 @@ def test_3886():
16701670
rms_1 = gentle_compare.pixmaps_rms(pixmap, pixmap_clean1)
16711671
print(f'test_3886(): {rms_0=} {rms_1=}')
16721672

1673+
def test_4415():
1674+
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4415.pdf')
1675+
path_out = os.path.normpath(f'{__file__}/../../tests/resources/test_4415_out.png')
1676+
path_out_expected = os.path.normpath(f'{__file__}/../../tests/resources/test_4415_out_expected.png')
1677+
with pymupdf.open(path) as document:
1678+
page = document[0]
1679+
rot = page.rotation
1680+
orig = pymupdf.Point(100, 100) # apparent insertion point
1681+
text = 'Text at Top-Left'
1682+
mrot = page.derotation_matrix # matrix annihilating page rotation
1683+
page.insert_text(orig * mrot, text, fontsize=60, rotate=rot)
1684+
pixmap = page.get_pixmap()
1685+
pixmap.save(path_out)
1686+
rms = gentle_compare.pixmaps_rms(path_out_expected, path_out)
1687+
assert rms == 0, f'{rms=}'

0 commit comments

Comments
 (0)