When the PDF created after deleting text by applying the add_redact_annot() function is opened in a web browser, the shapes are not displayed correctly.
How to reproduce the bug
doc = pymupdf.open(pdf_file)
for page in doc:
blks = page.get_text("blocks", sort=True, flags=pymupdf.TEXTFLAGS_DICT)
for blk in blks:
rect = pymupdf.Rect(blk[0], blk[1], blk[2], blk[3])
page.add_redact_annot(rect)
page.apply_redactions(images=0, graphics=0)
file_name, file_extension = os.path.splitext(pdf_file)
new_file = f"{file_name}_o{file_extension}"
doc.subset_fonts()
doc.ez_save(new_file, garbage=4)
doc.close()
Some of the information in the shapes is clustered at the bottom left of the page.
If you repair it using some repair tools, the file will display normally in the browser.
Description of the bug
When the PDF created after deleting text by applying the add_redact_annot() function is opened in a web browser, the shapes are not displayed correctly.
How to reproduce the bug
Some of the information in the shapes is clustered at the bottom left of the page.
If you repair it using some repair tools, the file will display normally in the browser.
The original file is as follows. sample_A.pdf
This is the file before applying add_redact_annot(). sample_A_red.pdf
The final file is as follows. sample_A_o.pdf
PyMuPDF version
1.24.7
Operating system
Windows
Python version
3.10