Created
December 9, 2024 18:28
-
-
Save vsDizzy/d0c5999cd213ab3b6490ef9234e3e4de to your computer and use it in GitHub Desktop.
PDF watermark remover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymupdf, sys, re | |
doc = pymupdf.open(sys.argv[1]) | |
for xref in range(1, doc.xref_length()): | |
pattern = r"(/Private /Watermark)|(/Name \(Watermark\))" | |
text = doc.xref_object(xref) | |
if re.search(pattern, text): | |
doc._deleteObject(xref) | |
name = doc.name.replace(".pdf", "-no-watermark.pdf") | |
doc.ez_save(name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment