diff --git a/README.md b/README.md index 53699652..c682b364 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ action [here](https://structure-vision.streamlit.app/). - Interactive zoom controls with multiple zoom options - Configurable alignment of the PDF viewer within its container - Optional horizontal separators between PDF pages +- Maximization toggle for expanded viewing within the component boundaries - Version 0.0.x provides an additional "legacy" viewer using the native pdf.js browser's, with limitations including no annotations, no scrolling - this is removed from version 0.1.x. @@ -96,12 +97,13 @@ In the following table the list of parameters that can be provided to the `pdf_v | annotation_outline_size | Size of the outline around each annotation in pixels. Defaults to 1 pixel. | | pages_to_render | Filter the rendering to a specific set of pages. By default, all pages are rendered. | | render_text | Enable a layer of text on top of the PDF document. The text may be selected and copied. **NOTE** to avoid breaking existing deployments, we made this optional at first, also considering that having many annotations might interfere with the copy-paste. | -| zoom_level | The zoom level of the PDF viewer. Can be a float (0.1-10.0), `"auto"` for fit-to-width, `"auto-height"` for fit-to-height, or `None` (defaults to auto-fit to width). When zoom controls are enabled, users can interactively adjust the zoom level. | -| viewer_align | The alignment of the PDF viewer within its container. Can be `"center"` (default), `"left"`, or `"right"`. | +| zoom_level | The zoom level of the PDF viewer. Can be a float (0.1-10.0), `"auto"` for fit-to-width, `"auto-height"` for fit-to-height, or `None` (defaults to auto-fit to width). When zoom controls are enabled, users can interactively adjust the zoom level. | +| viewer_align | The alignment of the PDF viewer within its container. Can be `"center"` (default), `"left"`, or `"right"`. | | show_page_separator | Whether to show a horizontal separator line between PDF pages. Defaults to `True`. | | scroll_to_page | Scroll to a specific page when the component is rendered. The parameter is an integer, which represent the positional value of the page. E.g. 1, will be the first page. Default is None. Require ints and ignores the parameters below zero. | | scroll_to_annotation | Scroll to a specific annotation when the component is rendered. The parameter is an integer, which represent the positional value of the annotation. E.g. 1, will be the first annotation. Default is None (don't scroll). Mutually exclusive with `scroll_to_page`. Raise an exception if used with `scroll_to_page` | | on_annotation_click | Callback function that is called when an annotation is clicked. The function receives the annotation as a parameter. | +| show_fullscreen_toggle | Whether to show a button to toggle maximized mode. This provides expanded viewing within the component boundaries rather than browser fullscreen. Defaults to `True`. | ### Annotation format diff --git a/streamlit_pdf_viewer/__init__.py b/streamlit_pdf_viewer/__init__.py index 995ef7c0..7caedf25 100644 --- a/streamlit_pdf_viewer/__init__.py +++ b/streamlit_pdf_viewer/__init__.py @@ -39,6 +39,7 @@ def pdf_viewer( scroll_to_page: Optional[int] = None, scroll_to_annotation: Optional[int] = None, on_annotation_click: Optional[Callable[[dict], None]] = None, + show_fullscreen_toggle: bool = True, ): """ pdf_viewer function to display a PDF file in a Streamlit app. @@ -59,6 +60,7 @@ def pdf_viewer( :param scroll_to_page: Scroll to a specific page in the PDF. The parameter is an integer, which represent the positional value of the page. E.g. 1, will be the first page. Defaults to None. :param scroll_to_annotation: Scroll to a specific annotation in the PDF. The parameter is an integer, which represent the positional value of the annotation. E.g. 1, will be the first annotation. Defaults to None. :param on_annotation_click: A callback function that will be called when an annotation is clicked. The function should accept a single argument, which is the annotation that was clicked. Defaults to None. + :param show_fullscreen_toggle: Whether to show button to toggle maximized mode. This provides expanded viewing within the component boundaries rather than browser fullscreen. Defaults to True. The function reads the PDF file (from a file path, URL, or binary data), encodes it in base64, and uses a Streamlit component to render it in the app. It supports optional annotations and adjustable margins. @@ -132,7 +134,8 @@ def pdf_viewer( viewer_align=viewer_align, show_page_separator=show_page_separator, scroll_to_page=scroll_to_page, - scroll_to_annotation=scroll_to_annotation + scroll_to_annotation=scroll_to_annotation, + show_fullscreen_toggle=show_fullscreen_toggle, ) # Execute the custom callback function diff --git a/streamlit_pdf_viewer/frontend/src/PdfViewer.vue b/streamlit_pdf_viewer/frontend/src/PdfViewer.vue index 25204531..7e52ec80 100644 --- a/streamlit_pdf_viewer/frontend/src/PdfViewer.vue +++ b/streamlit_pdf_viewer/frontend/src/PdfViewer.vue @@ -1,20 +1,26 @@