forked from Averell7/pyPdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Pure-Python PDF Library
License
kcmckell/pyPdf
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
#!/usr/bin/env python # -*- coding: utf-8 -*- import time from pyPdf_e import PdfFileWriter, PdfFileReader output = PdfFileWriter() input1 = PdfFileReader(file("pdf/demo.pdf", "rb")) start = time.time() for a in range(0, input1.getNumPages() - 2 , 2) : first = input1.getPage(a) second = input1.getPage(a + 1) width = first.mediaBox.getUpperRight_x() height = first.mediaBox.getUpperRight_y() first.mediaBox.upperRight = ( width * 2, height) first.mergeTranslatedPage(second,width,0) output.addPage(first) print a end = time.time() print "===>", end - start # finally, write "output" to document-output.pdf outputStream = file("document-output.pdf", "wb") output.write(outputStream) outputStream.close() output = PdfFileWriter() input1 = PdfFileReader(file("pdf/demo.pdf", "rb")) start = time.time() for a in range(0, input1.getNumPages() - 2 , 2) : new = output.addBlankPage(100,100) first = input1.getPage(a) second = input1.getPage(a + 1) width = first.mediaBox.getUpperRight_x() height = first.mediaBox.getUpperRight_y() new.mediaBox.upperRight = ( width * 2, height) data_x = [] data_x.append("q\n") data_x.append("0.9 0 0 0.9 0 0 cm") data_x.append(first) data_x.append("Q\n") data_x.append("q\n") data_x.append("1 0 0 1 595 0 cm ") data_x.append(second) data_x.append("Q\n") new.mergePage3(data_x) print a end = time.time() print "===>", end - start # finally, write "output" to document-output.pdf outputStream = file("document-output2.pdf", "wb") output.write(outputStream) outputStream.close()
About
Pure-Python PDF Library
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published