Skip to content

Undesired texts are removed when applying redaction #1074

Description

@hieu-lam

Hi,

I have a problem with Pymupdf redaction. The issue is basically some of the text around the annotated part is also deleted when apply redaction. You can see the example below:

image

After redaction, it will become:

image

I follow the instruction to use fitz.TOOLS.set_small_glyph_heights(on=True) and get the following result:

image

This time the annotated part has been smaller, but still the result is not as I expected:

image

I get the quads annotations from page.search_for() and add the redaction with page.add_redact_annot().

The code is as below:

page = doc.loadPage(0)
annot  = page.firstAnnot 
while annot:
    page.add_redact_annot(annot.rect, text=None, fontname=None, fontsize=11, align=0, fill=(1, 1, 1), text_color=(0, 0, 0))
    annot = annot.next 
page.apply_redactions()

Is there anyway to improve this?

And by the way, some of us use Adobe Reader tool to add the annotation manually. Those annotations could not be "squeeze", so the surrounding text is removed unwantedly.

The example below is an annotation made by Adobe Reader Comment tool.
image

On the Pymupdf it says: "Text removal is done by character: A character is removed if its bbox has a non-empty overlap with a redaction rectangle (changed in MuPDF v1.17)". I guess this is the main issue here. Is there anyway get around this with a fix?

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions