Replace the text from pdf saving the structure of the document #3499
-
| 
         Good day, I am attempting to use PyMuPDF to translate PDF files while preserving the formatting and structure of the document. Could you please provide an example of how I can extract text and replace it with the translated text? Thank you.  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
| 
         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: 
 Depending on results of this experiment, you can decide how and where to optimize the result.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         To provide inserted text with desired font weight / style always requires using the right (= different!) font. I.e. bold text means a different font was used than regular or italic text. So to cover all situations for e.g. Helvetica, you need 4 different fonts: Helvetica, Helvetica-Bold, Helvetica-BoldItalic and Helvetica-Italic.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Hello NikitaIVll, how is your project to translate PDF files going? I have a similar issue and would like to know how you are handling it.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Hi @bqhai199x @NikitaIVll @Ataraxiainc2 , can you help me here, if you were able to solve and make this pdf text translator tool woth structure preservation?? Also @JorjMcKie ,your help would be really grateful. I am still stuck on this for past 3-4 months! Would be really grateful!!  | 
  
Beta Was this translation helpful? Give feedback.
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: