Customizing the scale of PDF measurement tool

Each of the measurement tools and measurement annotations has a scale ratio and precision. These properties can be changed using the UI or programmatically.

Setting scale and precision with the UI

To set the measurement properties, select a tool or an annotation, the current scale will show in the overlay.

Apryse Docs Image

Click it will open the dropdown menu showing all the existing scales. The current scale is highlighted with blue color.

Apryse Docs Image

Click another scale, or click the Add New Scale button to create a new scale, and then it will be applied to the current tool or annotation.

Apryse Docs Image

In the Scale Modal above, click the Calibrate button to calibrate the scale and apply.

Apryse Docs Image

Setting scale and precision programmatically

You can take the same approach as shown in the Customizing tools guide to set measurement properties. Measurement related tool names include: AnnotationCreateDistanceMeasurement, AnnotationCreatePerimeterMeasurement and AnnotationCreateAreaMeasurement, etc.. You can view the list of valid tool names. The following example sets the scale and precision of the distance measurement tool:

1WebViewer(...)
2 .then(instance => {
3 const { documentViewer } = instance.Core;
4 const distanceMeasurementTool = documentViewer.getTool('AnnotationCreateDistanceMeasurement');
5
6 distanceMeasurementTool.setStyles({
7 // value of Scale is an array that is consisted of two arrays
8 // the first element in each array is the scale ratio and the second element is the unit.
9 // valid units are: mm, cm, m, km, mi, yd, ft, in and pt
10 // the following array means that for the annotations created by the distance measurement tool, 0.25 inches on the document is equal to 1 inch in the real world
11 Scale: [[0.25, 'in'], [1, 'in']],
12
13 // value of Precision is a number that means how many decimal places the calculated value should have
14 Precision: 0.001
15 });
16 });

Getting scale and precision programmatically

The following example logs the precision and scale of the distance measurement tool:

1WebViewer(...)
2 .then(instance => {
3 const { documentViewer } = instance.Core;
4 const distanceMeasurementTool = documentViewer.getTool('AnnotationCreateDistanceMeasurement');
5
6 console.log(distanceMeasurementTool.defaults.Scale);
7 console.log(distanceMeasurementTool.defaults.Precision);
8 });

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales