Skip to content

feat: measurement tools (distance, perimeter, area)#654

Open
MathiasWP wants to merge 2 commits into
embedpdf:mainfrom
MathiasWP:measure-tool-support
Open

feat: measurement tools (distance, perimeter, area)#654
MathiasWP wants to merge 2 commits into
embedpdf:mainfrom
MathiasWP:measure-tool-support

Conversation

@MathiasWP

@MathiasWP MathiasWP commented Jun 2, 2026

Copy link
Copy Markdown

Adds calibrated measurement tools — distance (line), perimeter (polyline), and area (polygon / rectangle / ellipse) — with live, zoom-stable labels, scale calibration (including draw-to-calibrate), units (mm/cm/m/in/ft/yd/pt), decimal/fractional precision, and an optional secondary unit.

Implementation: measurements are ordinary Line/Polyline/Polygon/Square/Circle annotations carrying typed measurement metadata; the unit/geometry math is a pure module in @embedpdf/models. Calibration is persisted via the /EPDFCustom data channel plus the spec /IT intent (a fully spec-compliant native /Measure dictionary for cross-viewer interop is deferred — it needs a pdfium WASM rebuild). Labels render across React/Preact/Vue/Svelte, and the snippet viewer gets a Measure mode (toolbar, draw-to-calibrate dialog, property panel) plus hold-Shift angle constraint.

Resolves #223

Add calibrated measurement tools (distance, perimeter, polygon/rectangle/
ellipse area) with live, zoom-stable labels, scale calibration (incl.
draw-to-calibrate), units (mm/cm/m/in/ft/yd/pt), decimal/fractional precision,
and an optional secondary unit.

Implementation: measurements are ordinary Line/Polyline/Polygon/Square/Circle
annotations carrying typed `measurement` metadata; pure math lives in
@embedpdf/models; persisted via the /EPDFCustom channel + spec /IT intent
(native /Measure dictionary deferred — needs a pdfium WASM rebuild). Rendered
across React/Preact/Vue/Svelte, with snippet-viewer UI (Measure mode, toolbar,
calibrate dialog, property panel) and hold-Shift angle constraint.
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

@MathiasWP is attempting to deploy a commit to the OpenBook Team on Vercel.

A member of the Team first needs to authorize it.

Fill rectangle/ellipse/polygon area measurements with a subtle 45° diagonal
hatch (mode === 'area' only) so the enclosed region reads as the measured area.
Sized in px/scale so density stays constant across zoom; shared AreaHatch
helper with Vue/Svelte mirrors.
@MathiasWP

Copy link
Copy Markdown
Author

@bobsingor thoughts on adding this? This is the missing piece for us to start using EmbedPDF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for measurement tools

1 participant