Add Zoom Controls, Alignment Options & Page-Separator Support#103
Conversation
…ameter with support for numeric values, 'auto', and 'auto-height' - Add viewer_align parameter for left/center/right alignment - Add show_page_separator parameter for optional horizontal lines between pages - Implement zoom controls with manual input, preset levels, and fit options - Add input validation and race condition protection for zoom functionality - Include example file demonstrating new features
…st files for zoom functionality (numeric, auto, auto-height) - Add separate test files for alignment functionality (left, center, right) - Add separate test files for page separator functionality (enabled/disabled) - Each test includes corresponding example Streamlit app for demonstration - Tests cover basic rendering, functionality verification, and visual positioning - Replace combined example with focused individual test cases
…ctors from id to class (.zoom-button) - Fix zoom control button text selectors (Zoom In/Zoom Out) - Update page separator tests to check CSS border styles instead of separate elements - Fix zoom_level parameter in auto zoom example (use None instead of 'auto') - 22/32 tests now passing
…l validation to allow string values ('auto', 'auto-height') - Update alignment positioning tests to check computed margin values instead of CSS 'auto' - Use realistic positioning assertions for center/right alignment - All zoom functionality tests: 12/12 ✅ - All alignment functionality tests: 12/12 ✅ - All page separator tests: 8/8 ✅ - Total: 32/32 tests passing across Firefox and Chromium browsers
…for precise constraints - Fix zoom_level, viewer_align, and rendering parameter types - Add Optional[] for nullable parameters - Add return type annotation - Update docstring for zoom_level parameter
|
@danieljannai Thanks!! That's great someone implemented such a big feature. 🚀 |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces three new ergonomic features to the PDF viewer component: interactive zoom controls, configurable viewer alignment, and optional page separators. Key changes include adding multiple zoom options (numeric values, "auto", and "auto-height"), aligning the viewer via a new parameter, and conditionally rendering horizontal separators between pages, with corresponding tests and documentation updates.
Reviewed Changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/* | New e2e tests covering zoom controls, auto zoom variants, page separator visibility, and viewer alignment |
| streamlit_pdf_viewer/frontend/src/PdfViewer.vue | Updated component template and script to include zoom controls, alignment logic, and page separator styling |
| streamlit_pdf_viewer/init.py | Updated parameter defaults and validations for zoom_level, viewer_align, and show_page_separator, with adjusted documentation |
| README.md | Documentation updated to reflect new features and options |
Comments suppressed due to low confidence (1)
streamlit_pdf_viewer/init.py:39
- There is a spelling error in the printed message: 'disapper' should read 'disappear'.
resolution_boost: int = 1,
|
HI @danieljannai, you did a terrific job. 🚀 I have one question, what is the More generally, I'm also wondering whether we could get rid of all the legacy stuff which are just a pain to maintain. |
|
Thanks @lfoppiano, just extended your terrific work 😄 The main idea behind With regards to legacy stuff, I 100% agree. It might be a breaking change, but it's necessary. Especially since many tests don't pass at the moment. |
|
@lfoppiano |
|
Separating config looks a bit too complicated, indeed. I would just like to make sure those two options don't clash:
Regarding the legacy rendering, we can release 0.1.0 and break compatibility. I think there is already a PR #96 |
Sure! 🎉 |
They don't seem to clash. Take a look at the attached screenshots:
|
|
@lfoppiano Added the auto-build during setup :) |
|
I'm going to merge and release 0.0.26, then dump the legacy stuff and release 0.1.0 🎉 |





This PR introduces three ergonomic improvements to streamlit-pdf-viewer:
Interactive Zoom
•
zoom_levelaccepts float,"auto","auto-height"orNone(default = fit-to-width).• Top-right dropdown with presets, ± buttons and manual entry.
Viewer Alignment
•
viewer_align="left" | "center" | "right"(default = center).Optional Page Separators
•
show_page_separator=True | False.Additional updates
No existing behaviour is changed; any failing CI checks stem from pre-existing legacy-mode tests.