-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdel-text.py
43 lines (24 loc) · 811 Bytes
/
del-text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pymupdf
import session
import datetime
print("Remove Text")
filename = input("Filename: ")
needle = input("Search for: ")
doc = pymupdf.open(filename)
total = 0
for index, page in enumerate(doc):
res = page.search_for(needle)
print("page #",index," ",len(res)," match found")
for found in res:
print(res)
total += 1
rq = input("Remove text? (y/n) ")
if(rq == "y" or rq == "Y"):
page.add_redact_annot(found, text=None, fontname=None, fontsize=11, fill=(1, 1, 1), text_color=(0, 0, 0), cross_out=True)
page.apply_redactions()
print("Text removed")
newfile = input("New filename: ")
doc.save(newfile)
session.add([datetime.datetime.now(),'remove_text',filename,needle])
doc.close()
print("Task complete")