Measure area, distance & perimeter in PDFs in Salesforce
Getting Started
We recommend the Overview page to learn how to correctly use a config.js before getting started with using Webviewer.
PDF documents allow line, polyline and polygon annotations to contain measurement information to measure the distance, perimeter and area of parts of a document. A scale is defined so that for example, one inch on the document is defined as one foot, allowing you determine the actual size of things in an architectural diagram once you know the scale.
Apryse SDK has built-in tools allowing you to create these annotations and provides a UI to modify common properties. There is also a more advanced programmatic API for fine grained control.
Setting Up
When creating a new instance of WebViewer, the enableMeasurement property needs to be set to true to display the measurement annotation tools in the UI
WebViewer({
... // other options
enableMeasurement: true
}, viewerElement);Besides passing in a constructor option, measurement can be toggled using the WebViewer API with the enableFeatures and disableFeatures functions in the config.js.
window.addEventListener('viewerLoaded', () => {
instance.UI.enableFeatures([instance.Feature.Measurement]);
}Measurement Annotations
To create measurement annotations in WebViewer, click on the measurement tool icon, select one of the tools. Next click and drag on the document to create a measurement annotation. An overlay with measurement information will show up when you are creating or selecting a measurement annotation.

The following example shows how you can determine if an annotation is a measurement annotation and logs the precision and scale of it after it's added:
Customization
Setting scale and precision with the UI
To set measurement properties for a tool, click on the measurement tool icon and select the tool. A style menu will pop up in which you can find and change the properties.

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 are: AnnotationCreateDistanceMeasurement, AnnotationCreatePerimeterMeasurement and AnnotationCreateAreaMeasurement. You can view the list of valid tool names. The following example sets the scale and precision of the distance measurement tool:
Getting scale and precision programmatically
The following example logs the precision and scale of the distance measurement tool:
Last updated
Was this helpful?