-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert-link.py
58 lines (36 loc) · 928 Bytes
/
insert-link.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
48
49
50
51
52
53
54
55
56
import pymupdf
print("Insert link")
filename = input("Filename: ")
doc = pymupdf.open(filename)
pgnum = int(input("Page: "))
page = doc[pgnum]
rx0 = int(input("Rect x0: "))
ry0 = int(input("Rect y0: "))
rx1 = int(input("Rect x1: "))
ry1 = int(input("Rect y1: "))
print("0: LINK_NONE")
print("1: LINK_GOTO")
print("2: LINK_URI")
print("3: LINK_LAUNCH")
print("4: LINK_NAMED")
print("5: LINK_GOTOR")
kind = int(input("Kind: (0-5) "))
if(kind == 0):
print("not supported")
elif(kind == 1):
print("not supported")
elif(kind == 2):
print("Internet uri")
uri = input("URI: ")
linkdict = {"kind":kind,"uri":uri, "from":pymupdf.Rect(rx0,ry0,rx1,ry1)}
elif(kind == 3):
print("not supported")
elif(kind == 4):
print("not supported")
elif(kind == 5):
print("not supported")
newfile = input("New file: ")
page.insert_link(linkdict)
doc.save(newfile)
print("Link inserted")
doc.close()