-
Notifications
You must be signed in to change notification settings - Fork 1
/
png2pdf.py
executable file
·81 lines (57 loc) · 1.51 KB
/
png2pdf.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 10 22:14:07 2019
@author: Owner
"""
from fpdf import FPDF
import glob
def png2pdf(nm):
drt = "/Users/sshanto/techmrt/Python_new/draft_2/experiment_1/figures/" + nm + "/"
ext = "experiment_1_combined_plots_" + drt.split("/")[6] + ".pdf"
#print(ext)
l = glob.glob(drt+"*.png")
print(drt+"*.png\n")
pdf = FPDF()
imagelist= l
x = 0
y = -5
w = 220
h = 180
for image in imagelist:
print(image)
pdf.add_page()
pdf.image(image,x,y,w,h)
drt = str(nm)+ "/"
pdf.output(drt+ext, "F")
#print(drt+ext)
#print("Done!\n")
f = glob.glob("/Users/sshanto/techmrt/Python_new/draft_2/experiment_1/figures/*")
for i in f:
t = i.split("\\")[0]
# print(t)
png2pdf(t)
g = glob.glob("draft_2/experiment_2/figures/*")
#print(g)
def exp_2_png2pdf(nm):
drt = "draft_2/experiment_2/figures/" + nm + "/"
ext = "experiment_2_combined_plots_" + drt.split("/")[3] + ".pdf"
print(ext)
l = glob.glob(drt+"*.png")
pdf = FPDF()
imagelist= l
x = 0
y = -5
w = 220
h = 180
for image in imagelist:
# print(image)
pdf.add_page()
pdf.image(image,x,y,w,h)
drt = "draft_2/experiment_2/figures/" + str(nm)+ "/"
pdf.output(drt+ext, "F")
print("Done!\n")
"""
for i in g:
t = i.split("\\")[1]
exp_2_png2pdf(t)
"""