Closed
Description
Description of the bug
Calling page.add_redact_annot()
in a specific PDF page results in segfault (segmentation fault (core dumped)).
How to reproduce the bug
import pymupdf
from pathlib import Path
import os
p = Path("./pdfs").glob("*")
out_dir = Path("./pdfs/out")
os.makedirs(out_dir, exist_ok=True)
files = [x for x in p if x.is_file()]
def replace_table_text(page: pymupdf.Page) -> pymupdf.Page:
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()
return page
doc = pymupdf.Document(files[0])
replace_table_text(doc[0])
file: test-1-24.pdf
PyMuPDF version
1.24.13
Operating system
Linux
Python version
3.12