A Streamlit component for viewing PDF files
Project Links
Meta
Author: Snowflake Inc
Maintainer: Snowflake Inc
Requires Python: >=3.9
Classifiers
Development Status
- 3 - Alpha
Intended Audience
- Developers
Programming Language
- Python :: 3
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
Topic
- Software Development :: Libraries :: Python Modules
- Office/Business :: Office Suites
- Multimedia :: Graphics :: Viewers
streamlit-pdf
A lightweight Streamlit feature that seamlessly displays PDF files in your apps, allowing for simple, responsive, and clean document viewing with minimal effort.
๐ฆ Installation
pip install streamlit[pdf]
Ensure you have Streamlit installed:
๐ก Usage
Here's how to display a PDF file in your Streamlit app:
import streamlit as st
# Display PDF from URL
st.pdf("https://example.com/document.pdf")
# Display with custom height
st.pdf("path/to/document.pdf", height=600)
# Display uploaded file
uploaded_file = st.file_uploader("Choose a PDF file", type="pdf")
if uploaded_file is not None:
st.pdf(uploaded_file)
โ๏ธ API Reference
st.pdf(data, height=600)
Parameters:
-
data(str | Path | bytes | BytesIO): The PDF file to show. This can be one of the following:- A URL (string) for a hosted PDF file (
"https://example.com/doc.pdf") - A path to a local PDF file (
"./documents/sample.pdf") - A file-like object, e.g. a file opened with
openor anUploadedFilereturned byst.file_uploader - Raw bytes data
- A URL (string) for a hosted PDF file (
-
height(int, optional): Height of the PDF viewer in pixels. Default: 600
๐ผ๏ธ Examples
Basic PDF Display
import streamlit as st
st.title("PDF Viewer Example")
# Display a PDF from URL
st.pdf("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")
File Upload with PDF Display
import streamlit as st
st.title("Upload and View PDF")
uploaded_file = st.file_uploader("Choose a PDF file", type="pdf")
if uploaded_file is not None:
st.pdf(uploaded_file)
Custom Height
import streamlit as st
# Display PDF with specific height
st.pdf("document.pdf", height=800)
# Display PDF with default height
st.pdf("document.pdf")
Reading from Local File
import streamlit as st
with open("document.pdf", "rb") as file:
st.pdf(file.read(), height=700)
๐ Contributing
Feel free to file issues in our Streamlit Repository.
Contributions are welcome ๐, however, please inform us before building a feature.
Development flow
Prerequisites:
uv venv .venv
source .venv/bin/activate
uv pip install -e '.[with-streamlit]' .
cd streamlit_pdf/frontend && npm install
- Build the frontend once:
npm run build
- Or run the frontend in watch/development mode:
npm run dev
2.1.0
Sep 28, 2026
2.0.1
Nov 18, 2025
2.0.0
Nov 13, 2025
1.0.8
Oct 13, 2025
1.0.7
Aug 28, 2025
1.0.6
Aug 14, 2025
1.0.5
Aug 08, 2025