title: Extracting text from a PDF - All pages and Output - file using Python
body: <p>Im new on Python.
  I am using this code to extract text. Is it possible extract all pages and have an output in a file?</p>
  
  <pre><code>import PyPDF2
  pdf_file = open('sample.pdf','rb')
  read_pdf = PyPDF2.PdfFileReader(pdf_file)
  number_of_pages = read_pdf.getNumPages()
  page = read_pdf.getPage(10)
  page_content = page.extractText()
  print (page_content)
  </code></pre>