Jul-08-2020, 10:30 AM
Dear forum users!
There is a pdf file, it is necessary to delete certain text in it. Then add new text below to the existing one.
I'm trying to use the PyMuPDF library - fitz. Open the file, set the text to search, but I did not find how to delete it and add new text.
Please could you help me how to delete the found text and add to the existing one.
Using libraries is not important, we can use PyPDF2 and others.
The sample pdf file with description is attached.
There is a pdf file, it is necessary to delete certain text in it. Then add new text below to the existing one.
I'm trying to use the PyMuPDF library - fitz. Open the file, set the text to search, but I did not find how to delete it and add new text.
Please could you help me how to delete the found text and add to the existing one.
Using libraries is not important, we can use PyPDF2 and others.
The sample pdf file with description is attached.
import fitz doc = fitz.open(MyFilePath) page = doc[0] text1 = “ANA” text_instances1 = page.searchFor(text1) # found text should be deleted … text_to_add = “Text” text2 = “TAIL NO.” text_instances2 = page.searchFor(text2) # should be added "text_to_add" after found text "text2" doc.save(OutputFilePath, garbage=4, deflate=True, clean=True)