|
import streamlit as st |
|
import base64 |
|
|
|
|
|
PDF_WIDTH = 700 |
|
PDF_HEIGHT = 1000 |
|
PDF_PATH = "./some_pdf.pdf" |
|
|
|
def display_pdf(file): |
|
|
|
with open(file, "rb") as f: |
|
base64_pdf = base64.b64encode(f.read()).decode('utf-8') |
|
|
|
|
|
pdf_display = F'<iframe src="data:application/pdf;base64,{base64_pdf}" width="{PDF_WIDTH}" height="{PDF_HEIGHT}" type="application/pdf"></iframe>' |
|
|
|
|
|
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") |
|
|