title: how to extract text in each line of a pdf file using python
body: <p>I have gone through many solutions for extracting data from pdf file but could not find a solution to this particular problem</p>
  
  <p>I have a pdf file that has the following data format in it</p>
  
  <pre><code>UPC             Product Description              Subcategory Name   Pkg type
  
  018894300199    Big Y Mozzarella String  16oz       16oz Pkg Cheese    PKG 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/sobP2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sobP2.png" alt="enter image description here"></a></p>
  
  <p>I need to extract the UPC, Product description and Sub name for each line of the pdf file using python </p>
  
  <p>I was able to extract the text from the pdf file using the code below </p>
  
  <pre><code>from PyPDF2 import PdfFileReader, PdfFileWriter
  
  
  
  pdfFileObj = open('grocery2.pdf', 'rb')
  pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
  
  
  print(pdfReader.numPages)
  
  pageObj = pdfReader.getPage(1)
  pagecontent = pageObj.extractText()
  </code></pre>
  
  <p>I have more than 500 pages of product data. what is the most efficient way of extracting the UPC, Product description  and Sub name for each line of the page? </p>