Created
October 30, 2016 08:43
-
-
Save mickn/9d87decf58e51382d95e501f75142571 to your computer and use it in GitHub Desktop.
Split PDF with spreads into separate pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import copy, sys | |
from pyPdf import PdfFileWriter, PdfFileReader | |
input = PdfFileReader(sys.stdin) | |
output = PdfFileWriter() | |
for p in [input.getPage(i) for i in range(0,input.getNumPages())]: | |
q = copy.copy(p) | |
(w, h) = p.mediaBox.upperRight | |
p.mediaBox.upperRight = (w/2, h) | |
q.mediaBox.upperLeft = (w/2, h) | |
output.addPage(p) | |
output.addPage(q) | |
output.write(sys.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment