NLP1 / app.py
amaanadeen's picture
Create app.py
611e56a
raw
history blame contribute delete
737 Bytes
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)