Streamlit PDF Viewer

raw JSON →
2.0.1 verified Fri May 01 auth: no python

A Streamlit custom component that renders PDF files directly in the browser. Version 2.0.1 supports embedded viewing, page navigation, and zoom controls. Maintained by the community with monthly releases.

pip install streamlit-pdf
error ModuleNotFoundError: No module named 'streamlit_pdf'
cause Old import path `streamlit-pdf` used in code, but the module is `streamlit_pdf` (underscore) or package not installed.
fix
Run pip install streamlit-pdf and ensure import uses underscore: from streamlit_pdf import st_pdf
error ImportError: cannot import name 'render_pdf' from 'streamlit_pdf'
cause Version 2.x removed `render_pdf`. Using v1.x syntax.
fix
Upgrade to v2.0.1: pip install --upgrade streamlit-pdf and use from streamlit_pdf import st_pdf
breaking Version 2.x majorly changed the API. The function `render_pdf` from 1.x is removed. Use `st_pdf` instead.
fix Replace `from streamlit_pdf import render_pdf` with `from streamlit_pdf import st_pdf`.
gotcha Local file paths must be passed as bytes or as a string path. If you pass a string URL, it is fetched; if you pass a Path object, it may fail.
fix Use `open('file.pdf', 'rb').read()` for local files or a string URL.
deprecated The `height` parameter in version 2.x might be ignored in some Streamlit builds; use CSS styling instead.
fix Apply custom CSS via `st.markdown` or use Streamlit's `st.columns` to control layout.

Minimal example to display a PDF from a URL.

import streamlit as st
from streamlit_pdf import st_pdf

st.title("PDF Viewer")

# Example: load PDF from URL
pdf_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"

# Or from local file: open('example.pdf', 'rb')
st_pdf(pdf_url, width=700, height=900)