title: PyPDF2 complete clone of file
body: <p>I am trying to copy a PDF in its entirety using PyPDF2, the following code copies the content but not the outline of the pdf.</p>
  
  <p><a href="http://www.pdf995.com/samples/pdf.pdf" rel="nofollow noreferrer">here is a sample pdf</a> and use the code as follows <code>python test.py &lt;input pdf&gt; &lt;output dest&gt;</code></p>
  
  <p>Here is the code that I have so far.</p>
  
  <pre><code>from PyPDF2 import PdfFileWriter, PdfFileReader
  import sys
  import os.path
  
  def main(argv):
      if not os.path.isfile(argv[0]) and \
      not os.path.isfile(argv[1]):
          print("Invalid path")
          sys.exit()
      input_pdf = PdfFileReader(open(argv[0], "rb"))
      output_pdf = PdfFileWriter()
      input_pdf_pages = input_pdf.getNumPages()
      for i in range(0, input_pdf_pages):
          output_pdf.addPage(input_pdf.getPage(i))
      output_pdf.write(open(argv[1], "wb"))
  
  if __name__ == "__main__":
      main(sys.argv[1:])
  </code></pre>