Can create last incomplete book
This commit is contained in:
parent
04fc7fe1b6
commit
9cf0b8e0de
1 changed files with 15 additions and 7 deletions
|
@ -100,7 +100,13 @@ def indice(text):
|
||||||
doc.build(parts)
|
doc.build(parts)
|
||||||
|
|
||||||
pdfReader = PdfFileReader(packet)
|
pdfReader = PdfFileReader(packet)
|
||||||
return([pdfReader.getPage(0),pdfReader.getPage(1)])
|
pdfWriter = PdfFileWriter()
|
||||||
|
|
||||||
|
for page in pdfReader.pages:
|
||||||
|
pdfWriter.addPage(page)
|
||||||
|
pdfWriter.addBlankPage()
|
||||||
|
|
||||||
|
return([pdfWriter.getPage(0),pdfWriter.getPage(1)])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,12 +256,13 @@ def main():
|
||||||
|
|
||||||
print("Genero i libretti")
|
print("Genero i libretti")
|
||||||
os.makedirs('books', exist_ok=True)
|
os.makedirs('books', exist_ok=True)
|
||||||
for book_num in range(1, int(len(vgo_dict) / 50) + 1):
|
for pagstart in range(1, len(vgo_dict), 50):
|
||||||
pdfWriter = PyPDF2.PdfFileWriter()
|
pdfWriter = PyPDF2.PdfFileWriter()
|
||||||
print(book_num)
|
|
||||||
|
|
||||||
pagstart = (book_num - 1) * 50 + 1
|
book_num = int(pagstart / 50) + 1
|
||||||
pagend = book_num * 50
|
pagend = min(book_num * 50, len(vgo_dict))
|
||||||
|
|
||||||
|
print(book_num)
|
||||||
|
|
||||||
# aggiungere copertina
|
# aggiungere copertina
|
||||||
pdfWriter.addPage(copertina(str(pagstart).zfill(3) + " - " + str(pagend).zfill(3)))
|
pdfWriter.addPage(copertina(str(pagstart).zfill(3) + " - " + str(pagend).zfill(3)))
|
||||||
|
@ -276,7 +283,8 @@ def main():
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
pdfWriter.addBlankPage()
|
for i in range(0, 8 - ((((pagend - 1) % 50) + 1 + 5) % 8)):
|
||||||
|
pdfWriter.addBlankPage()
|
||||||
|
|
||||||
# aggiungere indice
|
# aggiungere indice
|
||||||
for indpag in indice(indtext):
|
for indpag in indice(indtext):
|
||||||
|
@ -289,7 +297,7 @@ def main():
|
||||||
pageObj = pdfReader.getPage(0)
|
pageObj = pdfReader.getPage(0)
|
||||||
pdfWriter.addPage(pageObj)
|
pdfWriter.addPage(pageObj)
|
||||||
|
|
||||||
book_name = os.path.join('books', 'book' + str(book_num).zfill(2) + '.pdf')
|
book_name = os.path.join('books', 'vgo_' + str(book_num).zfill(2) + '.pdf')
|
||||||
with open(book_name, 'wb') as pdfOutput:
|
with open(book_name, 'wb') as pdfOutput:
|
||||||
pdfWriter.write(pdfOutput)
|
pdfWriter.write(pdfOutput)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue