title: How do you shift all pages of a PDF document right by one inch?
body: <p>I want to shift all the pages of an existing pdf document right one inch so they can be three hole punched without hitting the content.  The pdf documents will be already generated so changing the way they are generated is not possible.  </p>
  
  <p>It appears iText can do this from a <a href="https://stackoverflow.com/questions/3447720/how-can-i-shift-page-images-in-pdf-files-more-to-the-left-or-to-the-right">previous question</a>. </p>
  
  <p>What is an equivalent library (or way do this) for C++ or Python?</p>
  
  <p>If it is platform dependent I need one that would work on Linux.</p>
  
  <p><strong>Update:</strong> Figured I would post a little script I wrote to do this in case anyone else finds this page and needs it.</p>
  
  <p>Working code thanks to Scott Anderson's suggestion:</p>
  
  <p>rightshift.py</p>
  
  <pre><code>#!/usr/bin/python2
  import sys
  import os
  from  pyPdf import PdfFileReader, PdfFileWriter
  
  #not sure what default user space units are. 
  # just guessed until current document i was looking at worked
  uToShift = 50;
  
  if (len(sys.argv) &lt; 3):
    print "Usage rightshift [in_file] [out_file]"
    sys.exit()
  
  if not os.path.exists(sys.argv[1]):
    print "%s does not exist." % sys.argv[1]
    sys.exit()
  
  pdfInput = PdfFileReader(file( sys.argv[1], "rb"))
  pdfOutput = PdfFileWriter()
  
  pages=pdfInput.getNumPages()
  
  for i in range(0,pages):
    p = pdfInput.getPage(i)
    for box in (p.mediaBox, p.cropBox, p.bleedBox, p.trimBox, p.artBox):
      box.lowerLeft = (box.getLowerLeft_x() - uToShift, box.getLowerLeft_y())
      box.upperRight = (box.getUpperRight_x() - uToShift, box.getUpperRight_y())
    pdfOutput.addPage( p )
  
  outputStream = file(sys.argv[2], "wb")
  pdfOutput.write(outputStream)
  outputStream.close()
  </code></pre>