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