File size: 374 Bytes
5d4bf7d
2267014
5d4bf7d
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import fitz

def extract_text_from_pdf(pdf_file):
    try:
        document = fitz.open(stream=pdf_file.read(), filetype="pdf")
        text = ""
        for page_num in range(len(document)):
            page = document.load_page(page_num)
            text += page.get_text()
        return text
    except Exception as e:
        return f"Failed to load in text: {str(e)}"