streamlit-pdf


Namestreamlit-pdf JSON
Version 1.0.5 PyPI version JSON
download
home_pageNone
SummaryA Streamlit component for viewing PDF files
upload_time2025-08-08 20:30:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache-2.0
keywords streamlit pdf viewer react component
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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/cd/ed/47d7d0032ed2d475e46e62616bb581832509713a791e91e05fe2e0febc35/streamlit_pdf-1.0.5.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.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/streamlit/streamlit-pdf/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": "46904634f7abb2eedbc7f6b7841de374771676935ff80f4f3845b4a8f2cbcdc7",
                "md5": "2fbd60dfcef98cb3a816857465666937",
                "sha256": "099221766313c1fe2c349e852d8ec8162e63ba5b47531571cfb6aac1d215e8da"
            },
            "downloads": -1,
            "filename": "streamlit_pdf-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fbd60dfcef98cb3a816857465666937",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 2102635,
            "upload_time": "2025-08-08T20:30:31",
            "upload_time_iso_8601": "2025-08-08T20:30:31.178492Z",
            "url": "https://files.pythonhosted.org/packages/46/90/4634f7abb2eedbc7f6b7841de374771676935ff80f4f3845b4a8f2cbcdc7/streamlit_pdf-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cded47d7d0032ed2d475e46e62616bb581832509713a791e91e05fe2e0febc35",
                "md5": "e329d40f1d7f0e7c3a0c2b98cf33de77",
                "sha256": "eae17f1671b7e66090852f1622738df368dc60bf9835b5761e329f8675bcd7d2"
            },
            "downloads": -1,
            "filename": "streamlit_pdf-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e329d40f1d7f0e7c3a0c2b98cf33de77",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 1971392,
            "upload_time": "2025-08-08T20:30:33",
            "upload_time_iso_8601": "2025-08-08T20:30:33.118506Z",
            "url": "https://files.pythonhosted.org/packages/cd/ed/47d7d0032ed2d475e46e62616bb581832509713a791e91e05fe2e0febc35/streamlit_pdf-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-08 20:30:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "streamlit",
    "github_project": "streamlit-pdf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "streamlit-pdf"
}
        
Elapsed time: 1.94231s