Create download as csv button for html content in Streamlit

I am using Streamlit to create a page which has a pdf on the left side and an html file which represents data extracted from the pdf to the right. I have used this document for reference(Create a Download Button API to download files · Issue #2722 · streamlit/streamlit · GitHub).

However I am getting an error which states that “module ‘streamlit’ has no attribute ‘download_button’”. Can someone please help on this

My code is as follows:

import streamlit as st
import streamlit.components.v1 as components
import base64


st.header("PDF VIEWER")

c_left, c_right = st.beta_columns(2)

with c_right:
    HtmlFile = open("testtingfile.html", 'r', encoding='utf-8')
    source_code = 
    components.html(source_code, height= 1000, width=1000)
    st.download_button('Download CSV', source_code, 'text/csv')
    # st.download_button('Download CSV', text_contents)  # Defaults to 'text/plain'

    with open('myfile.csv', 't') as f:
        st.download_button('Download CSV', f)  # Defaults to 'text/plain'

# import base64
with c_left:
    with open("newfile.pdf", "rb") as pdf_file:
        base64_pdf = base64.b64encode('utf-8')
    # base64_pdf = base64.b64encode('utf-8')
    pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="700" height="1000" type="application/pdf">' 
    st.markdown(pdf_display, unsafe_allow_html=True)

@andfanilo Can you please help

Hello @Myntur,

The github link you’re referring to is still an open issue. That download_button is not part of Streamlit yet.

However you could try to use this implementation: