Menu

Why PDF annotations move when you rotate or zoom a page
📰

Why PDF annotations move when you rotate or zoom a page

DEV Community: frontend·KomoPDF·6 days ago
#fbpmaDWI
#devtofrontend#devto#dev#viewport#coordinates
Long article (860 words) — no AI summary yet.
Reading 0:00
15s threshold

A PDF viewer can put a signature in the wrong place even when the pointer coordinates look correct. The page might be rotated, zoomed, or displayed at a different size from its canvas bitmap. An overlay that happens to line up at 100% zoom can drift as soon as the user changes the view.

The fix starts with keeping two coordinate systems separate. Store an annotation in PDF page coordinates. Convert it to viewport coordinates when displaying it, and convert a pointer position back when the user edits it. PDF.js exposes both conversions on its page viewport.

Reproduce the offset

Use a page with a visible corner mark. Place an annotation near that mark, zoom in, then rotate the page by 90 degrees. Reopen the saved file in another viewer. If the annotation moves away from the mark, inspect how the placement was converted before blaming the export.

PDF page coordinates traditionally have their origin at the lower left and increase upward.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.