Skip to content

Commit

Permalink
src/__init__.py tests/: added test for #4047.
Browse files Browse the repository at this point in the history
Also added assert that will catch the problem in future.
  • Loading branch information
julian-smith-artifex-com committed Nov 14, 2024
1 parent 69891d3 commit fb905b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7750,6 +7750,7 @@ def _add_redact_annot(self, quad, text=None, da_str=None, align=0, fill=None, te
mupdf.pdf_array_push_real(arr, fcol[i])
mupdf.pdf_dict_put(mupdf.pdf_annot_obj(annot), PDF_NAME('IC'), arr)
if text:
assert da_str
mupdf.pdf_dict_puts(
mupdf.pdf_annot_obj(annot),
"OverlayText",
Expand Down
Binary file added tests/resources/test_4047.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/test_annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,17 @@ def test_parent():
assert str(e) == 'weakly-referenced object no longer exists'
else:
assert 0, f'Failed to get expected exception.'

def test_4047():
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4047.pdf')
with pymupdf.open(path) as document:
page = document[0]
fontname = page.get_fonts()[0][3]
if fontname not in pymupdf.Base14_fontnames:
fontname = "Courier"
hits = page.search_for("|")
for rect in hits:
page.add_redact_annot(
rect, " ", fontname=fontname, align=pymupdf.TEXT_ALIGN_CENTER, fontsize=10
) # Segmentation Fault...
page.apply_redactions()

0 comments on commit fb905b1

Please sign in to comment.