4

Can you guys fix the problem? I'm unable to read an arabic PDF file. I don't know what is the issue. Thanks

import PyPDF2

def main():

   with   open("arabic_text.pdf", encoding='utf-8') as pdfFile:
       pdfRead = PyPDF2.PdfFileReader(pdfFile)
       output = PdfFileWriter()

   for m in range(pdfRead.getNumPages()):
       page = pdfRead.getPage(m)
       pageContent = page.extractText()
       print(pageContent)

if __name__ == "__main__":
   main()


Shrief Nabil
  • 59
  • 1
  • 8

1 Answers1

9

Open the file with rb mode for the usage in PDF format. Example:

with open("arabic_text.pdf", 'rb'):
SuperStormer
  • 4,997
  • 5
  • 25
  • 35
rad123
  • 177
  • 2
  • 8