In django I get the file uploaded by the user with input_pdf = request.FILES['pdf']
and I want to extract fiel text with pdftextract
library with pdf = XPdf(input_pdf)
but it gives an error: TypeError: _getfullpathname: path should be string, bytes or os.PathLike, not InMemoryUploadedFile
. How should I get the path of the user uploaded file or how can I use pdftextract
with the data type InMemoryUploadedFile
.
I must say that for local files pdftextract
extract text with the following code:
from pdftextract import XPdf
file_path = "examples/pubmed_example.pdf"
pdf = XPdf(file_path)
txt = pdf.to_text()
print(txt)