# 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
```bash
pip install streamlit[pdf]
```
Ensure you have **Streamlit** installed:
---
## 💡 Usage
Here's how to display a PDF file in your Streamlit app:
```python
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 `open` or an `UploadedFile` returned by `st.file_uploader`
- Raw bytes data
- **`height`** (_int_, optional): Height of the PDF viewer in pixels. Default: 600
---
## 🖼️ Examples
### Basic PDF Display
```python
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
```python
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
```python
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
```python
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](https://github.com/streamlit/streamlit/issues/new/choose).
Contributions are welcome 🚀, however, please inform us before building a feature.
---
Raw data
{
"_id": null,
"home_page": null,
"name": "streamlit-pdf",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Snowflake Inc <hello@streamlit.io>",
"keywords": "streamlit, pdf, viewer, react, component",
"author": null,
"author_email": "Snowflake Inc <hello@streamlit.io>",
"download_url": "https://files.pythonhosted.org/packages/14/36/6aa63996edcc939c20c5bf155c7ead58a21072609c508de16f9bf78a7d3e/streamlit_pdf-1.0.7.tar.gz",
"platform": null,
"description": "# streamlit-pdf\n\nA lightweight **Streamlit** feature that seamlessly displays **PDF** files in your apps, allowing for simple, responsive, and clean document viewing with minimal effort.\n\n---\n\n## \ud83d\udce6 Installation\n\n```bash\npip install streamlit[pdf]\n```\n\nEnsure you have **Streamlit** installed:\n\n---\n\n## \ud83d\udca1 Usage\n\nHere's how to display a PDF file in your Streamlit app:\n\n```python\nimport streamlit as st\n\n# Display PDF from URL\nst.pdf(\"https://example.com/document.pdf\")\n\n# Display with custom height\nst.pdf(\"path/to/document.pdf\", height=600)\n\n# Display uploaded file\nuploaded_file = st.file_uploader(\"Choose a PDF file\", type=\"pdf\")\nif uploaded_file is not None:\n st.pdf(uploaded_file)\n```\n\n---\n\n## \u2699\ufe0f API Reference\n\n### `st.pdf(data, height=600)`\n\n#### Parameters:\n\n- **`data`** (_str | Path | bytes | BytesIO_): The PDF file to show. This can be one of the following:\n\n - A URL (string) for a hosted PDF file (`\"https://example.com/doc.pdf\"`)\n - A path to a local PDF file (`\"./documents/sample.pdf\"`)\n - A file-like object, e.g. a file opened with `open` or an `UploadedFile` returned by `st.file_uploader`\n - Raw bytes data\n\n- **`height`** (_int_, optional): Height of the PDF viewer in pixels. Default: 600\n\n---\n\n## \ud83d\uddbc\ufe0f Examples\n\n### Basic PDF Display\n\n```python\nimport streamlit as st\n\nst.title(\"PDF Viewer Example\")\n\n# Display a PDF from URL\nst.pdf(\"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf\")\n```\n\n### File Upload with PDF Display\n\n```python\nimport streamlit as st\n\nst.title(\"Upload and View PDF\")\n\nuploaded_file = st.file_uploader(\"Choose a PDF file\", type=\"pdf\")\nif uploaded_file is not None:\n st.pdf(uploaded_file)\n```\n\n### Custom Height\n\n```python\nimport streamlit as st\n\n# Display PDF with specific height\nst.pdf(\"document.pdf\", height=800)\n\n# Display PDF with default height\nst.pdf(\"document.pdf\")\n```\n\n### Reading from Local File\n\n```python\nimport streamlit as st\n\nwith open(\"document.pdf\", \"rb\") as file:\n st.pdf(file.read(), height=700)\n```\n\n---\n\n## \ud83d\udcdd Contributing\n\nFeel free to file issues in [our Streamlit Repository](https://github.com/streamlit/streamlit/issues/new/choose).\n\nContributions are welcome \ud83d\ude80, however, please inform us before building a feature.\n\n---\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A Streamlit component for viewing PDF files",
"version": "1.0.7",
"project_urls": {
"Bug Tracker": "https://github.com/streamlit/streamlit/issues",
"Community": "https://discuss.streamlit.io/",
"Homepage": "https://streamlit.io",
"Source Code": "https://github.com/streamlit/streamlit-pdf",
"Twitter": "https://twitter.com/streamlit"
},
"split_keywords": [
"streamlit",
" pdf",
" viewer",
" react",
" component"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "39cf09a87edd0d6b69a6f497790cf4ddcbab29648d51513f96c7e97d38515482",
"md5": "fd401d9adf5da2e6f6e9b271f60c4669",
"sha256": "e08227c0435e1cf4b45288a468dd7513affd8ff58231636d2b49939749d699ea"
},
"downloads": -1,
"filename": "streamlit_pdf-1.0.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fd401d9adf5da2e6f6e9b271f60c4669",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 2103330,
"upload_time": "2025-08-28T20:20:20",
"upload_time_iso_8601": "2025-08-28T20:20:20.812204Z",
"url": "https://files.pythonhosted.org/packages/39/cf/09a87edd0d6b69a6f497790cf4ddcbab29648d51513f96c7e97d38515482/streamlit_pdf-1.0.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "14366aa63996edcc939c20c5bf155c7ead58a21072609c508de16f9bf78a7d3e",
"md5": "1e0f1f42f60a60fd9ad58333cc5513f5",
"sha256": "8405e86dfc9072f93c6aa1293579f917f0e13bd7848ea60b1dcb74b5fc75e23d"
},
"downloads": -1,
"filename": "streamlit_pdf-1.0.7.tar.gz",
"has_sig": false,
"md5_digest": "1e0f1f42f60a60fd9ad58333cc5513f5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 1971873,
"upload_time": "2025-08-28T20:20:22",
"upload_time_iso_8601": "2025-08-28T20:20:22.662626Z",
"url": "https://files.pythonhosted.org/packages/14/36/6aa63996edcc939c20c5bf155c7ead58a21072609c508de16f9bf78a7d3e/streamlit_pdf-1.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-28 20:20:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "streamlit",
"github_project": "streamlit",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "streamlit-pdf"
}