feat(viewer): add zoom controls to processing pdf viewer#63
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #57.
Adds a zoom toolbar (−, %, +, Reset) to the processing PDF viewer (
scan_process.html, used in steps 1, 2, and 3). Range 0.5x – 3x, step 0.1. Step 1 persists its zoom level independently from steps 2/3, since reviewing page numbers and reviewing opinions benefit from different zooms.How it works
The toolbar lives at the top-left of the viewer panel and stays visible when you scroll, even horizontally at high zoom. Each PDF page is scaled visually as a whole, so detection boxes, redactions, and image overlays all stay aligned with the page automatically. Drawing a new redaction or detection, and dragging or resizing existing ones, works the same at any zoom level.
pdf.js rasterizes each page once into a canvas at a fixed resolution, so simply CSS-scaling that bitmap to a higher zoom looks really blurry above the original render scale (the same effect as zooming into a JPEG). To avoid this, when the zoom level changes the viewer re-rasterizes visible pages at the new resolution so text stays sharp. Pages outside the viewport are dropped and re-rendered fresh when scrolled back into view, which keeps memory bounded at high zoom on long documents. Rapid zoom clicks are debounced and any in-flight render is cancelled when zoom changes again, the same pattern pdf.js's own demo viewer uses.
The page header (PDF p.n + action buttons) also got a small layout tweak: at narrow widths (low zoom or small monitors) the buttons wrap below the page identifier instead of overflowing the page width.