File size: 1,112 Bytes
03dc960
 
 
 
e30a304
a898358
e30a304
 
 
 
03dc960
 
 
 
e30a304
 
 
 
 
 
a898358
03dc960
 
a898358
 
03dc960
a898358
03dc960
 
 
 
 
 
 
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
34
35
"""
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()