File size: 878 Bytes
157b326
f93da68
 
157b326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
027467a
 
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
32
33
import streamlit as st
import base64


PDF_WIDTH = 700
PDF_HEIGHT = 1000
PDF_PATH = "./some_pdf.pdf"

def display_pdf(file):
    # Opening file from file path
    with open(file, "rb") as f:
        base64_pdf = base64.b64encode(f.read()).decode('utf-8')

    # Embedding PDF in HTML
    pdf_display = F'<iframe src="data:application/pdf;base64,{base64_pdf}" width="{PDF_WIDTH}" height="{PDF_HEIGHT}" type="application/pdf"></iframe>'
    
    # Displaying File
    st.markdown(pdf_display, unsafe_allow_html=True)

st.title("Welcome to PDF viewer 2000!")

st.markdown("## This is a markdown title")

st.markdown("I want to display the _best_ PDF of my **collection**!")

st.markdown("Learn more what a pdf is [here](https://en.wikipedia.org/wiki/PDF).")

st.sidebar.markdown("_Hint_: you can also display things on the sidebar.")

display_pdf(PDF_PATH)

st.markdown("Goodbye")