title: What is the correct way of extracting texts using pypdf2
body: <p>I am trying to extract text from a <a href="https://drive.google.com/file/d/1mkYhc6LjOcZufBUxud7Xu7asN6au6gxu/view?usp=sharing" rel="nofollow noreferrer">pdf</a> file. I am using the following code for this task:</p>
  <pre><code>def get_pdf_text(file):
      pdffile = PyPDF2.PdfFileReader(file)
      numpages = pdffile.getNumPages()
      for pages in range(0,numpages):
          currpage = pdffile.getPage(pages)
          content = currpage.extractText().encode('UTF-8')
      return content
  </code></pre>
  <p>However ,the output I am getting is very different from the source file:</p>
  <pre><code>b'Inheritance is a basic concept of Object\n-\nOriented Programming where\n \nthe basic idea is to create new classes that add extra detail to\n \nexisting classes.
   This is done by allowing the new classes to reuse\n \nthe methods and variables of the existing classes and new methods and\n \nclasses are added to specialise the new class.
   Inheritance models the\n \n\n-\nkind\n-\n\nbjects), for example,\n \npostgraduates and undergraduates are both kinds of student. This kind\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \nclass exten\n\n \n \nInheritance can occur on several layers, where if visualised would\n \ndisplay a larger tree structure. For example, we could further extend\n \n\n \n\n\n \n\n \n\n \n\n \n'
  </code></pre>
  <p>Not only there are multiple <code>\n</code> occuring in unexpected locations, some of the content also seems to be missing.
  I can't seem to find a fix.
  Thank you in advance for your help</p>