title: convert from pdf to text: lines and words are broken
body: <p>I want to convert a pdf file to text by PyPDF2 but converted text looks differents from PDF file. Specifically, one line in PDF is broken into multiple lines in text and words may be broken as well. Attached is the PDF and the text file I got with the code below. Could anyone help me fix this issue?</p>
  <pre class="lang-py prettyprint-override"><code>from PyPDF2 import PdfFileReader
  
  
  def extract_pdf_text(file_path=&quot;&quot;):
      reader = PdfFileReader(file_path)
  
      text = &quot;&quot;
  
      # Loop over all the pdf pages.
      for page in reader.pages:
          text = text + page.extractText()
      return text
  
  pdf_text = extract_pdf_text(&quot;PDF file path&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xyTiG.jpg" rel="nofollow noreferrer">pdf file</a></p>
  <p><a href="https://i.stack.imgur.com/16LAH.jpg" rel="nofollow noreferrer">converted text</a></p>