How to display a pdf content fullsize

how to display pdf content full size. iframe doesnt display it as the whole page

        merged_buffer = io.BytesIO()
        output_pdf.write(merged_buffer)

        merged_buffer.seek(0)

        pdf_content = merged_buffer.read()
        pdf_base64 = base64.b64encode(pdf_content).decode('utf-8')

pdf content code looks like this

Hi @Charlieletscode,

You could try and see if this code works for you. Adjust the height and width as required.

import streamlit as st
import base64

def ViewPDF(wch_fl):
    with open(wch_fl,"rb") as pdf_file:
        base64_pdf = base64.b64encode(pdf_file.read()).decode('utf-8')
        pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="1000" height="500" type="application/pdf">' 
        st.markdown(pdf_display, unsafe_allow_html=True)

ViewPDF("./tst.pdf")    # provide file path + full file name

Cheers


yeah but it still doesn fulfill fullscreen. I believe that there is no such function. answer could be open not restrict to streamlit

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.