From f9c0dc257f2e9f2931f530c037c766587d40792a Mon Sep 17 00:00:00 2001 From: Maya Barnes Date: Mon, 28 Sep 2026 10:28:16 -0700 Subject: [PATCH] [docs] Document pdf_viewer alt in README Surface the package API and accessible-name param on PyPI so 2.1.0 release notes match the shipped pdf_viewer signature. Co-authored-by: Cursor --- README.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d378b66..bbebdd0 100644 --- a/README.md +++ b/README.md @@ -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"`) @@ -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 @@ -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