Skip to content

Commit

Permalink
Update app.py with read in app feature
Browse files Browse the repository at this point in the history
  • Loading branch information
EdemGold committed Nov 27, 2023
1 parent 4ad995f commit 26cf311
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
import streamlit as st
import pandas as pd
from pathlib import Path
from pathlib import Path
from PyPDF2 import PdfFileWriter, PdfFileReader
import uuid

st.title("PDF Viewer App")

pdfs = {}

# Allow multiple uploads with a while loop
uploaded = True
# Allow multiple uploads
uploaded = True

while uploaded:
key = str(uuid.uuid4())
uploaded_file = st.file_uploader("Choose a PDF", type=['pdf'], key=key)

key = str(uuid.uuid4())
uploaded_file = st.file_uploader("Choose PDF", type=['pdf'], key=key)

if uploaded_file is not None:
file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type}

file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type}
pdfs[uploaded_file.name] = uploaded_file.read()

# Save to temp file
with open(Path("temp.pdf"), "wb") as f:
f.write(uploaded_file.getbuffer())

# Read PDF
pdf_reader = PdfFileReader(Path("temp.pdf"))

# Display pages
for page_num in range(pdf_reader.numPages):
page = pdf_reader.getPage(page_num)
st.write(page)

else:
uploaded = False
uploaded = False

# Display all uploaded PDFs
for name, data in pdfs.items():
# List uploaded PDFs
for name in pdfs:
st.write(name)
if st.checkbox(f'Show {name}'):
st.write(data)

0 comments on commit 26cf311

Please sign in to comment.