-
Notifications
You must be signed in to change notification settings - Fork 0
/
pixmap.py
56 lines (30 loc) · 887 Bytes
/
pixmap.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
def exportPage(doc,pgno):
page = doc[pgno]
pix = page.get_pixmap(dpi=150)
exported = input("Exported image (add .png):")
pix.save(exported) # "page-%i.png" % page.number
print("pixmap saved")
morepages = input("Do more pages? (y/n) ")
if(morepages == "y" or morepages == "Y"):
return True
else:
return False
def enterPage(doc):
pgnum = input("Page: ")
pgnum = int(pgnum)
res = exportPage(doc,pgnum)
if(res == True):
enterPage()
def enterDocument():
print("Please input the target file: ")
filename = input("Filename: ")
doc = pymupdf.open(filename)
enterPage(doc)
doc.close()
moredocs = input("Do more documents? (y/n) ")
if(moredocs == "y" or moredocs == "Y"):
enterDocument()
else:
print("Task completed")
enterDocument()