Skip to content

Commit 5ce8e78

Browse files
tests/: added test for #4079.
Test currently expects the current broken behaviour.
1 parent c3a91ad commit 5ce8e78

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

tests/resources/test_4079.pdf

126 KB
Binary file not shown.
138 KB
Binary file not shown.

tests/test_annots.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,32 @@ def test_4047():
472472
rect, " ", fontname=fontname, align=pymupdf.TEXT_ALIGN_CENTER, fontsize=10
473473
) # Segmentation Fault...
474474
page.apply_redactions()
475+
476+
def test_4079():
477+
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4079.pdf')
478+
path_after = os.path.normpath(f'{__file__}/../../tests/resources/test_4079_after.pdf')
479+
path_out = os.path.normpath(f'{__file__}/../../tests/test_4079_out')
480+
with pymupdf.open(path_after) as document_after:
481+
page = document_after[0]
482+
pixmap_after_expected = page.get_pixmap()
483+
with pymupdf.open(path) as document:
484+
page = document[0]
485+
rects = [
486+
[164,213,282,227],
487+
[282,213,397,233],
488+
[434,209,525,243],
489+
[169,228,231,243],
490+
[377,592,440,607],
491+
[373,611,444,626],
492+
]
493+
for rect in rects:
494+
page.add_redact_annot(rect, fill=(1,0,0))
495+
page.draw_rect(rect, color=(0, 1, 0))
496+
document.save(f'{path_out}_before.pdf')
497+
page.apply_redactions(images=0)
498+
pixmap_after = page.get_pixmap()
499+
document.save(f'{path_out}_after.pdf')
500+
rms = gentle_compare.pixmaps_rms(pixmap_after_expected, pixmap_after)
501+
print(f'{rms=}')
502+
# 2024-11-27 Expect current broken behaviour.
503+
assert rms == 0

0 commit comments

Comments
 (0)