Skip to content

Double layered Text is not redacted #1219

Description

@MallRoy

Please provide all mandatory information!

Describe the bug (mandatory)

I have a document with double-layered text. One Layer of the text is redacted and another one is left as it is. Both the text are in the same area.

To Reproduce (mandatory)

microsoftout.pdf

# imports
import fitz
import sys
from matplotlib import colors


class Redactor:
        doc = fitz.open('microsoftout.pdf')
        # iterating through pages
        for page in doc:
            if not page._isWrapped:
                page.wrapContents()

            currentpage = page.number
            dl = page.getDisplayList()
            tp = dl.getTextPage()
            clips=tp.search('cloud',quads=False)
            for clip in clips:
                print(clip)
                getInfo=fitz.Rect(clip)
                print(getInfo)
                delta = fitz.Point(0, getInfo.height) * 0.3
                new_rect = fitz.Rect(getInfo.tl + delta, getInfo.br - delta)
                page.addRedactAnnot(new_rect, fill=colors.to_rgb('yellow'))
                page.apply_redactions()

        # saving it to a new pdf
        doc.save('out.pdf',garbage=4,deflate=True,clean=True,linear=True)
        print("Completed")

# driver code for testing
if __name__ == "__main__":

    lines = sys.stdin.readlines()
    redactor = Redactor()
    redactor.redaction()

Expected behavior (optional)

Both the double-layered text should be removed.

Screenshots (optional)

image

Your configuration (mandatory)

  • Windows 10

Additional context (optional)

Metadata

Metadata

Assignees

Labels

not a bugnot a bug / user error / unable to reproduce

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