How PDF Annotation Coordinates Work
Understanding how PDF coordinates differ from screen coordinates explains why rotated or cropped PDFs frequently misalign annotations in simpler tools.
Bottom-left user space vs. visual top-left space
Unlike HTML Canvas or SVG (where origin (0, 0) sits at the top-left corner and Y increases downward), PDF user space places (0, 0) at the bottom-left of the page’s /MediaBox, measured in typographic points (1 pt = 1/72 inch).
Two additional page attributes complicate geometry further: /CropBox shifts the visible origin away from (0, 0), and /Rotate (0°, 90°, 180°, or 270°) rotates the rendered page without changing raw user-space coordinates stored in annotations.
Rect vs. QuadPoints
Every PDF annotation carries a /Rect [x1 y1 x2 y2] bounding box. Text markup annotations (Highlight, Underline, StrikeOut, Squiggly) additionally carry /QuadPoints: 8 coordinates per highlighted line segment representing the four corners of each quad.
Relying on /Rect alone for a highlight that starts near the end of line 1 and finishes near the start of line 2 erroneously encompasses the entire width of both lines. Extracting and reconstructing per-line QuadPoints keeps multi-line highlights tight and accurate.
Processed locally in your browser with zero file uploads.