Metadata-Version: 2.4
Name: streamlit-pdf
Version: 2.0.0
Summary: A Streamlit component for viewing PDF files
Author-email: Snowflake Inc <hello@streamlit.io>
Maintainer-email: Snowflake Inc <hello@streamlit.io>
License-Expression: Apache-2.0
Project-URL: Homepage, https://streamlit.io
Project-URL: Source Code, https://github.com/streamlit/streamlit-pdf
Project-URL: Bug Tracker, https://github.com/streamlit/streamlit/issues
Project-URL: Community, https://discuss.streamlit.io/
Project-URL: Twitter, https://twitter.com/streamlit
Keywords: streamlit,pdf,viewer,react,component
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Office/Business :: Office Suites
Classifier: Topic :: Multimedia :: Graphics :: Viewers
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICES
Provides-Extra: devel
Requires-Dist: wheel; extra == "devel"
Requires-Dist: pytest==7.4.0; extra == "devel"
Requires-Dist: playwright==1.49.*; extra == "devel"
Requires-Dist: requests==2.31.0; extra == "devel"
Requires-Dist: pytest-playwright-snapshot==1.0; extra == "devel"
Requires-Dist: pytest-rerunfailures==12.0; extra == "devel"
Provides-Extra: with-streamlit
Requires-Dist: streamlit>=1.51.0; extra == "with-streamlit"
Dynamic: license-file

# 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.

### Development flow

Prerequisites:

```bash
uv venv .venv
source .venv/bin/activate
uv pip install -e '.[with-streamlit]' .
cd streamlit_pdf/frontend && npm install
```

- Build the frontend once:
  ```bash
  npm run build
  ```
- Or run the frontend in watch/development mode:
  ```bash
  npm run dev
  ```

---
