2017-02-08 22:55:14 +00:00
|
|
|
import errno, os, PIL, fpdf
|
2017-02-08 22:49:18 +00:00
|
|
|
|
|
|
|
def makeDir(issue):
|
|
|
|
try:
|
|
|
|
os.makedirs(str(issue))
|
|
|
|
return True
|
|
|
|
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno != errno.EEXIST:
|
|
|
|
raise
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
def makePDF(issue, pages):
|
2017-02-08 22:52:34 +00:00
|
|
|
cover = PIL.Image.open("%s/1.jpg" % str(issue))
|
2017-02-08 22:49:18 +00:00
|
|
|
x, y = cover.size
|
|
|
|
|
|
|
|
pdf = fpdf.FPDF(unit = "pt", format = [x, y])
|
|
|
|
|
|
|
|
for page in range(pages):
|
|
|
|
pdf.add_page()
|
2017-02-08 22:52:34 +00:00
|
|
|
pdf.image("%s/%i.jpg" % (str(issue), page + 1), 0, 0)
|
2017-02-08 22:49:18 +00:00
|
|
|
|
2017-02-08 22:52:34 +00:00
|
|
|
pdf.output("%s/issue.pdf" % str(issue), "F")
|
2017-02-08 22:49:18 +00:00
|
|
|
|