Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ Here are some caveats to be aware of:
- If you need to use all the available space and limit the height, you can encapsulate the `pdf_viewer()` into a
`st.component(width:...)` setting the width.
- The `legacy` rendering has been removed from version 0.1.x+

## Streamlit compatibility

Streamlit ≥ 1.41 has a regression in custom-component iframe handling that can reset the page
scroll position after an `st.dialog` is closed — see issue
[#107](https://github.com/lfoppiano/streamlit-pdf-viewer/issues/107) for details and the bisect
data. The last fully working Streamlit version in our testing is 1.40.2.

If this regression affects your app, pin `streamlit<1.41` in your requirements. A runtime
`UserWarning` is emitted at import time whenever a newer Streamlit is detected.

## Getting started

```sh
Expand Down
21 changes: 21 additions & 0 deletions streamlit_pdf_viewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
import streamlit.components.v1 as components
import json

# Streamlit >= 1.41 introduced a regression in custom-component iframe handling
# that resets the page scroll position after an st.dialog is closed (see
# https://github.com/lfoppiano/streamlit-pdf-viewer/issues/107). Surface this to
# users at import time so it's visible without reading release notes.
try:
import warnings as _warnings
import streamlit as _st
from packaging.version import Version as _V

if _V(_st.__version__) >= _V("1.41.0"):
_warnings.warn(
"streamlit-pdf-viewer: Streamlit >= 1.41 has a known regression "
"that may reset the page scroll after an st.dialog is closed. "
"See https://github.com/lfoppiano/streamlit-pdf-viewer/issues/107 . "
"Pin streamlit<1.41 if this affects your app.",
UserWarning,
stacklevel=2,
)
except Exception:
pass

_RELEASE = True

if not _RELEASE:
Expand Down
Loading