Skip to content

Replace the text from pdf saving the structure of the document #3499

Answered by JorjMcKie
NikitaIVll asked this question in Q&A
Discussion options

You must be logged in to vote

I cannot give you complete code for this.

But the standard way (and extremely popular among our users) for replacing text are redaction annotations. Do a search in the documentation using "redaction".

The approach should be as follows:

  • Extract current text. If you want to know the font and other text properties, you will need the "dict" extraction option.
  • Translate it.
  • Remove old text using using redactions. This needs the the text coordinates (bbox).
  • Insert new text using a suitable font. The font from the old text (embedded in the PDF) is not usable!
  • Because new text will not fit in the same rectangle as the old one, you will have to find some way around this. Probably the best solutio…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@NikitaIVll
Comment options

@Ataraxiainc2
Comment options

Answer selected by NikitaIVll
Comment options

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

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants