import streamlit as st from PyPDF2 import PdfReader import base64 # Function to display the PDF def display_pdf(pdf_path): # Reading PDF file and converting it to base64 to display in Streamlit with open(pdf_path, "rb") as pdf_file: pdf_bytes = pdf_file.read() pdf_base64 = base64.b64encode(pdf_bytes).decode('utf-8') # Display the PDF in Streamlit using an HTML tag pdf_display = f'' st.markdown(pdf_display, unsafe_allow_html=True) # Title of the app st.title("Diagnostic Pathology Test Results - PDF Report") # Option to upload PDF file if needed pdf_file = st.file_uploader("Upload PDF Report", type="pdf") # If the user uploads a PDF, display it if pdf_file is not None: st.write("### Displaying Uploaded Report") display_pdf(pdf_file) else: # Or display a static PDF from your local machine st.write("### Displaying Static PDF Report") display_pdf("path_to_your_pdf_report.pdf") # Replace with the path to your static PDF