File size: 1,097 Bytes
e94d989
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
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'<embed src="data:application/pdf;base64,{pdf_base64}" width="700" height="900" type="application/pdf">'
    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