Merge branch 'pdftk_shuffler' into 'master'

Use pdftk in zine_maker rather than pdfseparate

See merge request mara/zine_maker!1
This commit is contained in:
Mara Karagianni 2022-04-30 10:47:31 +00:00
commit 77819fe2d6
2 changed files with 8 additions and 1 deletions

View file

@ -16,8 +16,15 @@ def shuffle_zine(finput, foutput):
# set font for all text
zine = Zine(orientation="P", unit="mm", format="A5")
chapter_list = zine.shuffle_chapters(finput)
with open('chapters.txt', 'w') as chapt:
for i in chapter_list:
chapt.write(i)
chapt.write("\n")
proc = subprocess.Popen(
["pdfunite"] + chapter_list + [foutput],
# ["pdftk"] + ["$(cat chapters.txt)", "cat", "output"] + [foutput],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE

View file

@ -62,7 +62,7 @@ class Zine(FPDF):
# TODO add 2 blank pages after the cover and colophon
# check if we have an odd number of pages
subprocess.run(
["pdfseparate", "%s" % pdfinput, "./%02d_chapter.pdf"],
["pdftk", "%s" % pdfinput, "burst", "output", "./%02d_chapter.pdf"],
stdout=subprocess.PIPE, text=True)
pages = glob.glob("./*_chapter.pdf")
pages.sort()