A Streamlit component for viewing PDF files
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_pdf-1.0.6.tar.gz.
File metadata
- Download URL: streamlit_pdf-1.0.6.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eaf1f6db0a8ebbbf2dc89ceece99c20e3438212b8ff2038e7d4ae93761f6617
|
|
| MD5 |
55a98c499c76e1b8f2c49f94d0a7688b
|
|
| BLAKE2b-256 |
9b4a7267192151c4979bb5729c07a88030402b245ab76b456f7b97ade63c8906
|
Provenance
The following attestation bundles were made for streamlit_pdf-1.0.6.tar.gz:
Publisher:
release.yml on streamlit/streamlit-pdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_pdf-1.0.6.tar.gz -
Subject digest:
7eaf1f6db0a8ebbbf2dc89ceece99c20e3438212b8ff2038e7d4ae93761f6617 - Sigstore transparency entry: 395503489
- Sigstore integration time:
-
Permalink:
streamlit/streamlit-pdf@03cc6c6e969a74e0c3be4c2c4b69c20bfe5675a7 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/streamlit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@03cc6c6e969a74e0c3be4c2c4b69c20bfe5675a7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file streamlit_pdf-1.0.6-py3-none-any.whl.
File metadata
- Download URL: streamlit_pdf-1.0.6-py3-none-any.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3322f3c43567919a7df8540e6ea0bdad684ea561b1f63f1686dbdf61c406f63
|
|
| MD5 |
3c29832c3f01972f09b0b7259db4aede
|
|
| BLAKE2b-256 |
7fd691187f8eaea64c8a4f8a88b6d717593c6777a95d7fabd301b5830ab1dfcb
|
Provenance
The following attestation bundles were made for streamlit_pdf-1.0.6-py3-none-any.whl:
Publisher:
release.yml on streamlit/streamlit-pdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_pdf-1.0.6-py3-none-any.whl -
Subject digest:
a3322f3c43567919a7df8540e6ea0bdad684ea561b1f63f1686dbdf61c406f63 - Sigstore transparency entry: 395503512
- Sigstore integration time:
-
Permalink:
streamlit/streamlit-pdf@03cc6c6e969a74e0c3be4c2c4b69c20bfe5675a7 -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/streamlit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@03cc6c6e969a74e0c3be4c2c4b69c20bfe5675a7 -
Trigger Event:
workflow_dispatch
-
Statement type: