From 5783f23cc4b0e2cf12b9890304a77f313f35e60b Mon Sep 17 00:00:00 2001 From: Mara Karagianni Date: Sat, 30 Apr 2022 12:45:33 +0200 Subject: [PATCH] Use pdftk in zine_maker rather than pdfseparate --- shuffle_pdf.py | 7 +++++++ zine_maker.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/shuffle_pdf.py b/shuffle_pdf.py index 21d57e1..68c8664 100644 --- a/shuffle_pdf.py +++ b/shuffle_pdf.py @@ -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 diff --git a/zine_maker.py b/zine_maker.py index 6e19871..68bb141 100644 --- a/zine_maker.py +++ b/zine_maker.py @@ -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()