Some test text!

Search
Hamburger Icon

Web / Guides / Customize

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.

Current scale in overlay

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

Existing scales in overlay

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.

Create new scale

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

Calibrate scale

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:

WebViewer(...)
  .then(instance => {
    const { documentViewer } = instance.Core;
    const distanceMeasurementTool = documentViewer.getTool('AnnotationCreateDistanceMeasurement');

    distanceMeasurementTool.setStyles({
      // value of Scale is an array that is consisted of two arrays
      // the first element in each array is the scale ratio and the second element is the unit.
      // valid units are: mm, cm, m, km, mi, yd, ft, in and pt
      // 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
      Scale: [[0.25, 'in'], [1, 'in']],

      // value of Precision is a number that means how many decimal places the calculated value should have
      Precision: 0.001
    });
  });

Getting scale and precision programmatically

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

WebViewer(...)
  .then(instance => {
    const { documentViewer } = instance.Core;
    const distanceMeasurementTool = documentViewer.getTool('AnnotationCreateDistanceMeasurement');

    console.log(distanceMeasurementTool.defaults.Scale);
    console.log(distanceMeasurementTool.defaults.Precision);
  });

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales