File size: 571 Bytes
cd41c7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st
import pymupdf
from io import StringIO

st.write("## Local RAG \n Get Insights from your documents")

file = st.file_uploader("Upload your Document Here", type=['pdf'])

if file is not None:
    # doc = pymupdf.open(file)
    # texts = [page.get_text().encode("utf-8") for page in doc]
    # texts

    # To read file as bytes:
    bytes_data = file.getvalue()
    with open("data/uploaded_file.pdf", "wb") as fp:
        fp.write(bytes_data)
        doc = pymupdf.open(fp)

    texts = [page.get_text().encode("utf-8") for page in doc]
    texts