Forums

Translating PyCharm programs over to PythonAnywhere

I'm new to Python and PythonAnywhere - but I've successful run a simple pdf file reader in PyCharm - but can't seem to get it to work in PythonAnywhere.

from PyPDF4 import PdfFileReader
reader = PdfFileReader('*.pdf')
number_of_pages = len(reader.pages)
print (number_of_pages)
page = reader.pages[0]
text = page.extractText()
print (text)

It successfully prints the number of pages - but I get a mess for the text. (!"#$#%&""'()*+#,-+./&0#123456#374 ...) Is there something obvious I'm missing. PS It is a text based pdf file that will open in PythonAnywhere and display the pages and text.

Is PdfFileReader supporting glob patterns for the stream argument? Maybe try a File object or a full path to the pdf file?