Alignment changes in some of the pdf file after replace text and replaced text is hidden #1997
-
Hi,
Some files it is working fine but for some files the replaced text is not visible when opening the file after replace. and when we search for a term it highlights some ir-releant term in pdf viewer software. i have attached source and replaced file for |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I did not try out your files and the code yet, but this sounds like one of the typical issues where pages contain "unprotected" addressing scheme changes - see the docs here. |
Beta Was this translation helpful? Give feedback.
-
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! page=doc[0]
page.clean_contents()
for r in rl:
page.add_redact_annot(r, text)
page.apply_redactions()
doc.save("y.pdf") In neither case appears your funny text. |
Beta Was this translation helpful? Give feedback.
Something must be wrong with your script. Here is what I did:
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.
In n…