-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert-text.py
50 lines (27 loc) · 926 Bytes
/
insert-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
44
45
46
47
import pymupdf
print("Insert text")
filename = input("Filename: ")
pgnum = int(input("Page: "))
doc = pymupdf.open(filename)
px = int(input("Point x: "))
py = int(input("Point y: "))
#rx1 = int(input("Rect x1: "))
#ry1 = int(input("Rect y1: "))
pt = pymupdf.Point(px,py)
instext = input("Text content: ")
fontsize = int(input("Font size: "))
rotate = int(input("Rotate(x90): "))
page = doc[pgnum]
rc = page.insert_text(pt, # bottom-left of 1st char
instext,
fontname = "helv", # the default font
fontsize = fontsize, # the default font size
rotate = rotate, # also available: 90, 180, 270
)
export = input("New filename: ")
doc.save(export)
print("Text inserted: ", export)
import session
import datetime
session.add([datetime.datetime.now(),'insert_text',px,py,filename,export])
doc.close()