Spaces:
Build error
Build error
File size: 737 Bytes
611e56a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import streamlit as st
import PyPDF2
from io import BytesIO
# Function to extract text from PDF
def extract_text_from_pdf(file):
pdfReader = PyPDF2.PdfReader(file)
text = ""
for page in pdfReader.pages:
text += page.extract_text()
return text
# Streamlit interface
st.title("PDF Text Extractor by FSA")
# File uploader
uploaded_file = st.file_uploader("Upload your PDF file", type="pdf")
if uploaded_file is not None:
# To read file as bytes:
bytes_data = BytesIO(uploaded_file.getvalue())
# Extracting text from the PDF
extracted_text = extract_text_from_pdf(bytes_data)
# Displaying the extracted text
st.write("Extracted Text:")
st.text_area("Text", extracted_text, height=300)
|