Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,28 @@ if uploaded_file is not None:
st.pdf(uploaded_file)
```

`st.pdf` wraps this package's `pdf_viewer`. You can also call the package API directly:

```python
import streamlit_pdf

streamlit_pdf.pdf_viewer(
"report.pdf",
alt="Q3 2026 financial report",
)
```

---

## ⚙️ API Reference

### `st.pdf(data, height=600)`
### `streamlit_pdf.pdf_viewer(file, height=600, key=None, *, alt=None)`

Most apps use `st.pdf(...)`, which wraps this component.

#### Parameters:

- **`data`** (_str | Path | bytes | BytesIO_): The PDF file to show. This can be one of the following:
- **`file`** (_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"`)
Expand All @@ -50,6 +63,10 @@ if uploaded_file is not None:

- **`height`** (_int_, optional): Height of the PDF viewer in pixels. Default: 600

- **`key`** (_str | None_, optional): An optional key that uniquely identifies this component instance.

- **`alt`** (_str | None_, optional): An accessible name for the PDF viewer. When provided (and non-blank), it is exposed as `aria-label` on the viewer root. Empty or whitespace-only values are omitted. Keyword-only.

---

## 🖼️ Examples
Expand Down Expand Up @@ -89,6 +106,17 @@ st.pdf("document.pdf", height=800)
st.pdf("document.pdf")
```

### Accessible name

```python
import streamlit_pdf

streamlit_pdf.pdf_viewer(
"document.pdf",
alt="Q3 2026 financial report",
)
```

### Reading from Local File

```python
Expand Down
Loading