hoehermann / pypdf_strreplace

Search and replace text in PDF files with PyPDF.
Other
8 stars 0 forks source link

The text was replaced but the script wrote over it #2

Open lganibenq opened 1 month ago

lganibenq commented 1 month ago

image (I dont have modify anything in the script)

hoehermann commented 1 month ago

Thank you for the report.

Unfortunately, this is a common problem. I guess, in your PDF, the text is positioned very explicitly. A human designer (or a layout engine) decided where each character should be. Can you share the original PDF with me? In case I can work on the project, it is nice to have the specific data to develop against.

I could probably make the tool smarter (e.g. shift text to the right), but PDF is a complex format and there are many things I would need to consider. Even if I would make the tool smarter, I could only handle a single line. Changing a paragraph (with wrapped text or even hyphenation) is definitely out of scope for a free tool. For that, you need to get one of the "big guns":

If you want to stick to this tool, you might try some of the workarounds:

I am grateful this tool is being appreciated. Unfortunately, I do currently not have enough spare time for further development. Contributions are welcome. :)