Skip to content
Discussion options

You must be logged in to vote

Something must be wrong with your script. Here is what I did:

page=doc[0]
rl=page.search_for(stext)

spans=[]
for r in rl:
    for b in page.get_text("dict",clip=r)["blocks"]:
        for l in b["lines"]:
            for s in l["spans"]:
                spans.append(s)

page.apply_redactions()

for s in spans:
    bbox=s["bbox"]
    fsize=s["size"]
    origin=s["origin"]
    page.insert_text(origin, text,fontsize=fsize)

doc.save("x.pdf")

And it does work!
The following also work, but the text is fairly small because it had to be shrinked to fit the old place.

page=doc[0]
page.clean_contents()
for r in rl:
    page.add_redact_annot(r, text)

page.apply_redactions()

doc.save("y.pdf")

In n…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
7 replies
@jayakumar0612
Comment options

@JorjMcKie
Comment options

@jayakumar0612
Comment options

@JorjMcKie
Comment options

@jayakumar0612
Comment options

Comment options

You must be logged in to vote
1 reply
@jayakumar0612
Comment options

Answer selected by jayakumar0612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants