Changeset 714
- Timestamp:
- 01/27/06 13:44:27 (3 years ago)
- Files:
-
- pypdf/trunk/README (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pypdf/trunk/README
r689 r714 4 4 5 5 output = PdfFileWriter() 6 input1 = PdfFileReader(file("document1.pdf", "rb")) 6 7 7 input1 = PdfFileReader(file("document1.pdf", "rb"))8 # add page 1 from input1 to output document, unchanged 8 9 output.addPage(input1.getPage(0)) 9 10 10 input2 = PdfFileReader(file("document2.pdf", "rb")) 11 for i in range(input2.getNumPages()): 12 output.addPage(input2.getPage(i).rotateClockwise(90)) 11 # add page 2 from input1, but rotated clockwise 90 degrees 12 output.addPage(input1.getPage(1).rotateClockwise(90)) 13 13 14 # add page 3 from input1, rotated the other way: 15 output.addPage(input1.getPage(2).rotateCounterClockwise(90)) 16 # alt: output.addPage(input1.getPage(2).rotateClockwise(270)) 17 18 # add page 4 from input1, but first add a watermark from another pdf: 19 page4 = input1.getPage(3) 20 watermark = PdfFileReader(file("watermark.pdf", "rb")) 21 page4.mergePage(watermark.getPage(0)) 22 23 # add page 5 from input1, but crop it to half size: 24 page5 = input1.getPage(4) 25 page5.mediaBox.upperRight = ( 26 page5.mediaBox.getUpperRight_x() / 2, 27 page5.mediaBox.getUpperRight_y() / 2 28 ) 29 output.addPage(page5) 30 31 # print how many pages input1 has: 32 print "document1.pdf has %s pages." % input1.getNumPages()) 33 34 # finally, write "output" to document-output.pdf 14 35 outputStream = file("document-output.pdf", "wb") 15 36 output.write(outputStream)
