gaurav
gaurav

Reputation: 3

I passed the file object but still getting parse error with slate3k

I am trying to read the text data of pdf file using "slate3k" . It seems fine to me. But I am getting parse error

I have been using "python3.7" .

import slate3k

with open("/home/am-it/Desktop/PythonLearning/pdf_practice/invoice-1.pdf","rb")as file:
    doc = slate3k.PDF(file)
    print(doc)

The Output of above code should be text from pdf. but the actual output is

 "Traceback (most recent call last):
  File "/home/am-it/Desktop/PythonLearning/pdf_practice/invoslate.py", line 4, in <module>
    doc = slate3k.PDF(file)
  File "/home/administrator/.local/lib/python3.7/site-packages/slate3k/classes.py", line 59, in __init__
    self.doc = PDFDocument()
TypeError: __init__() missing 1 required positional argument: 'parser'" 

I have passed the proper file object but still getting error. So please enlighten me

Upvotes: 0

Views: 1054

Answers (2)

alex oro
alex oro

Reputation: 11

Mine works well with single quotes and with print not indented

import slate3k as slt
with open('pdfPythonTest.pdf','rb') as f:
    extracted_text=slt.PDF(f)
print(extracted_text)

Hope this helps!

Upvotes: 0

Joao Ferraz
Joao Ferraz

Reputation: 11

Dude, in this part of the code: with open("/home/am-it/Desktop/PythonLearning/pdf_practice/invoice-1.pdf","rb")as file:

you have to write the name of the file plus the extension and not the path. So, try this: with open("invoice-1.pdf","rb")as file:

Upvotes: -1

Related Questions