I have successfully installed pyPDF, but the extractText method does not work well, so i decided to try pyPDF2, the problem is, when extracting text there is an exception:
Traceback (most recent call last):
File "C:\Users\Asus\Desktop\pfdtest.py", line 44, in <module>
test2()
File "C:\Users\Asus\Desktop\pfdtest.py", line 41, in test2
print(mypdf.getPage(0).extractText())
File "C:\Python32\lib\site-packages\PyPDF2\pdf.py", line 1701, in extractText
content = ContentStream(content, self.pdf)
File "C:\Python32\lib\site-packages\PyPDF2\pdf.py", line 1783, in __init__
stream = StringIO(stream.getData())
TypeError: initial_value must be str or None, not bytes
and this is my sample code:
filename = "myfile.pdf"
f = open(filename,'rb')
mypdf = PdfFileReader(f)
print(f,mypdf,mypdf.getNumPages())
print(mypdf.getPage(0).extractText())
It correctly determines the amount of pages in the pdf, but it has a problem with reading the stream.