title: How can I rotate a page with PyPDF2?
body: <p>I'm editing a PDF file with pyPDF2. I managed to generate the PDF I want but I've yet to rotate some pages.</p>
  <p>I went to <a href="https://pythonhosted.org/PyPDF2/PageObject.html" rel="nofollow noreferrer">the documentation</a> and found two methods: <code>rotateClockwise</code> and <code>rotateCounterClockwise</code>, and while they say the parameter is an <strong>int</strong>, I can't make it work. Python says:</p>
  <pre><code>TypeError: unsupported operand type(s) for +: 'IndirectObject' and 'int'
  </code></pre>
  <p>To produce this error:</p>
  <pre class="lang-py prettyprint-override"><code>from PyPDF2 import PdfFileReader, PdfFileWriter
  
  
  reader = PdfFileReader(&quot;example.pdf&quot;)
  
  with open(&quot;out.pdf&quot;, &quot;wb&quot;) as fh:
      writer = PdfFileWriter(fh)
      page = reader.getPage(0)
      page.rotateCounterClockwise(90)
      writer.addPage(page)
  </code></pre>
  <p>I can't find someone explaining the procedure. There is, however, a <a href="https://stackoverflow.com/questions/20646375/pypdf-indirectobject-in-rotate">question</a> in stackoverflow but the answer's just vague.</p>