0

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

Iguananaut
  • 21,810
  • 5
  • 50
  • 63
gaurav
  • 3
  • 3

2 Answers2

0

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!

alex oro
  • 11
  • 1
-1

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:

  • That's not correct. You can include a path as well as the file name and extension. https://docs.python.org/3.7/library/functions.html#open – David Buck Nov 23 '19 at 09:43