Can we hide or disable download button when display the PDF?

I want to disable the download button when i display the pdf.
Below is my code.

def show_pdf(file_path):
        with open(file_path,"rb") as f:
            base64_pdf = base64.b64encode('utf-8')
        pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="800" height="800" type="application/pdf"></iframe>'
        st.markdown(pdf_display, unsafe_allow_html=True)

    pdf_url = [pdf_file["download_url"] for pdf_file in pdf_files if pdf_file["name"] == filename + ".pdf"][0]
    response = requests.get(pdf_url)
    with open("temp.pdf", "wb") as f:

I dont want anyone that open this apps to download the pdf that i display. So can we hide the dowload button there as shown below. Please help me.


Anything that shows up in the browser has been already downloaded.

understand. But I want to display the pdf only so I want to disable the download button in that pdf reader. So users can only read but cannot download.

Unfortunately, that isn’t possible as far as I’m aware. Browsers ship with in-built PDF viewers/readers. And those PDF viewers vary across browser vendors. Streamlit does not ship its own.

If you want to disable the in-built PDF viewer’s download button, you’ll have to figure out a workaround at the browser-level (not at the Streamlit app level) and ensure your solution can apply to any users’ browsers – which may not be technically possible. I’m open to being proven wrong though :smile: