Created
October 6, 2010 04:59
-
-
Save jongyeol/612853 to your computer and use it in GitHub Desktop.
Rotate a pdf to landscape for Kindle
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/python | |
# Rotate a pdf to landscape for Kindle | |
# http://gist.github.com/612853 | |
# coded by jong10 <jong10@gmail.com> | |
# Usage (example) | |
# > python rotate-pdf.py input.pdf output.pdf | |
# supress deprecated warnings | |
import warnings | |
warnings.simplefilter('ignore', DeprecationWarning) | |
import sys | |
import pyPdf | |
if __name__ == '__main__': | |
if len(sys.argv) != 3: | |
print 'Usage: %s [input-pdf] [output-pdf]' % sys.argv[0] | |
exit(1) | |
o = pyPdf.PdfFileWriter() | |
i = pyPdf.PdfFileReader(file(sys.argv[1], "rb")); | |
for p in i.pages: | |
o.addPage(p.rotateCounterClockwise(90)) | |
ostream = file(sys.argv[2], "wb") | |
o.write(ostream) | |
ostream.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment