Scale Settings
Set document scale to ensure accurate measurements on the canvas.
To ensure scaling and measurements work reliably, always follow this integration flow:
- 1. Load Canvas: Initialize the canvas iframe.
- 2. Load File: Send the
viewmessage to load a document. - 3. Apply Scale: Use
addScaleonly AFTER the file is loaded. - 4. Activate Tools: Finally, enable measurement tools.
Scale logic is context-aware. You cannot apply a scale unless a document is active in the canvas. If you call addScale before view, the settings will be ignored.
Scale defines the relationship between canvas pixels and real-world dimensions. Without it, measurements like length and area cannot be calculated accurately.
- Two-way communication: Request current scales or push new scales.
- Metric and Imperial: Native support for both unit systems.
- Flexible scoping: Apply scales globally, per-page, or by page range.
Send a scale to the canvas and listen for the confirmation.
Most integration issues stem from understanding the difference between ratio values and multipliers.
- label: Display name shown to users (e.g.,
"1 m : 10 m") - value: The mathematical ratio as a string (e.g.,
"1:10"). - metric: Unit system -
"0"for Metric,"1"for Imperial - metricUnit: The exact unit name (e.g.,
"Meter","Feet"). Strict naming required. - dimPrecision: Decimal places for rounding (0-4)
- isSelected: Set to
trueto activate this scale immediately
IMPORTANT: You must use these exact unit names. Using shortcodes like "m" or "ft" will result in a silent failure.
- Metric:
Millimeter,Centimeter,Decimeter,Meter,Kilometer - Imperial:
Inch,Feet,Yard,Mile,Nautical Miles
The scale system uses a request-response pattern:
1. Request Current Scales
Ask the canvas for the current scale state.
2. Receive Snapshot
The canvas sends back the complete scale state.
3. Update Scale
Apply the scale only AFTER receiving a file load event.
For complex layouts, you can apply scales to specific page ranges or handle architectural fractions.
Calibration is documented separately because it is an interactive calculate-then-apply workflow rather than a direct addScale update.
- Calibration docs: Open Calibration
A production-ready implementation with initialization and event handling.
The complete ViewerScale interface with all available properties.
