Spaces:
Runtime error
Runtime error
| """ | |
| Page which shows the dissertation download button and the dissertation inline in a frame | |
| """ | |
| import streamlit as st | |
| import base64 | |
| from src.st_helpers import st_setup | |
| def show_download_button() -> None: | |
| """ | |
| Displays a button on the page which will download the dissertation PDF | |
| """ | |
| with open("img/dissertation.pdf", "rb") as f: | |
| pdf_bytes = f.read() | |
| st.download_button(label="Download dissertation", | |
| data=pdf_bytes, | |
| file_name="dissertation.pdf", | |
| mime='application/octet-stream') | |
| def show_dissertation_inline() -> None: | |
| with open("img/dissertation.pdf", "rb") as f: | |
| base64_pdf = base64.b64encode(f.read()).decode('utf-8') | |
| pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="1000" height="1500" type="application/pdf"></iframe>' | |
| st.markdown(pdf_display, unsafe_allow_html=True) | |
| if st_setup('Dissertation'): | |
| st.write("# Dissertation") | |
| st.write("The dissertation is delivered as a PDF document.") | |
| show_download_button() | |
| show_dissertation_inline() | |