title: How to open Russian-language PDFs for NLTK processing
body: <p>I'm trying to extract text from a pdf file in Russian, and use this text as data for tokenisation, lemmatisation etc. with NLTK on Jupyter Notebook. I'm using PyPDF2, but I keep running into problems.</p>
  <p>I am creating a function and passing to it the pdf as the input:</p>
  <p>from PyPDF2 import PdfFileReader</p>
  <p>def getTextPDF(pdfFileName):
  pdf_file = open(pdfFileName, &quot;rb&quot;)
  read_pdf = PdfFileReader(pdf_file)</p>
  <pre><code>text = []
  
  for i in range(0, read_pdf.getNumPages()):
      text.append(read_pdf.getPage(i).extractText())
  return &quot;\n&quot;.join(text)
  </code></pre>
  <p>Then I call the function:</p>
  <p>pdfFile = &quot;sample_russian.pdf&quot;
  print(&quot;PDF: \n&quot;, myreader_pdf.getTextPDF(pdfFile))</p>
  <p>But I get a long pink list of the same error warning:</p>
  <p>PdfReadWarning: Superfluous whitespace found in object header b'1' b'0' [pdf.py:.....]</p>
  <p>Any ideas would be very helpful! Thanks in advance!</p>