from pdf2image import convert_from_path import pytesseract def returnTextFromFile(file): pages = convert_from_path(file) text="" #text=pytesseract.image_to_string(pages[0]) for page in pages: text+=pytesseract.image_to_string(page) return text