Home
Zinner? I hardly know her.
So, I needed to print foldable zines, and after struggling for way too long with online tools that barely work, I made my own command-line converter.
It takes any pdf file as an input, just run ./zinner.py path/to/file.pdf to generate file-zinned.pdf in the same folder.
#!/usr/bin/env python
from pypdf import PdfWriter
from sys import argv
def main(path:str):
assert path[-4:]==".pdf", "B-baka, that's not a pdf! (-‸ლ)"
def order(n):
total = 4*(((n-1)//4)+1)
L=[]
for k in range(total//4):
L.append(2*k)
L.append(total-2*k-1)
L.append(total-2*k-2)
L.append(2*k+1)
return L
input_file = PdfWriter(clone_from=path)
n = len(input_file.pages)
for _ in range( 4*(((n-1)//4)+1) - n ):
input_file.add_blank_page()
shuffled_file = PdfWriter()
shuffled_file.append(input_file,order(n))
WIDTH = shuffled_file.pages[0].mediabox.width
HEIGHT = shuffled_file.pages[0].mediabox.height
output_file = PdfWriter()
for k in range(len(shuffled_file.pages)//2):
output_file.add_blank_page(width=2*WIDTH,height=HEIGHT)
output_file.pages[k].merge_translated_page(shuffled_file.pages[2*k+1],0,0)
output_file.pages[k].merge_translated_page(shuffled_file.pages[2*k],WIDTH,0)
output_file.write(path[:-4]+"-zinned.pdf")
main(argv[1])
It works on my machine with Python 3.13.7 and pypdf 6.0.0.
2026-03-24 EDIT: It didn’t work anymore on my machine today and I noticed a typo in the script, which generated a manga reading order, so I guessed it never really worked to begin with. 🤦 In any case, it is fixed and now it works on my machine with Python 3.14.3 and pypdf 6.9.2-1.