Removing watermark text #4879
Unanswered
BerndRusitschka
asked this question in
Looking for help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I apologize in advance if this topic has already been answerd. Maybe then you could simply point me to the solution.
I am using the PyMuPDF library to extract tables from PDF files. Therefore I use page.find_tables() which works really well in my case.
A small number of tables has a diagonal textual watermark in the background. When I extract the text from the single table cells, some of them will contain the part of the watermark within the cell boundaries as noise.
I can analyse the watermark by using page.get_text(“dict”) and looking for the “dir” field in the dictionary. If it contains a value pair different than (1.0, 0.0) or (0.0, -1.0) I know it’s a watermark.
What I would like to do now is to delete the watermark text or to override it with an empty string before extracting the table with page.find_tables().
I already saw that one could alter a PDF page with the information in the xref table but up to now I did not manage to code this correctly.
Can anybody give me a hint or a code snippet how to identify the watermark text in the xref table and how to write the change back to the PDF page?
Every comment is welcome even if it were “This can’t be done”.
I posted the same question here: https://forum.mupdf.com/t/removing-watermark-text/269
Beta Was this translation helpful? Give feedback.
All reactions