Measure Distance in a PDF Using JavaScript
Measure distance in a PDF using PSPDFKit for Web starting with version 2022.5. To measure distance in your app, contact the Sales team to add the Measurement Tools component to your license, or run the SDK in trial mode.
Measure distance in one of the following ways:
Measuring Distance between Two Points
Measure the distance between two points in one of the following ways:
Measuring Distance between Two Points Using the Built-In UI
To measure the distance between two points using the built-in UI, follow these steps:
-
Click the measurement tools icon.
-
Tap Distance.
-
Draw a straight line between the two points you want to measure.
Measuring Distance between Two Points Programmatically
To measure the distance between two points programmatically, use the LineAnnotation
shape constructor, which takes a measurementScale
property and a measurementPrecision
property as its parameters. For more information on scale and precision, see the guide on configuring measurements.
Measuring Distance between Multiple Connected Points
Measure the distance between multiple connected points in one of the following ways:
Measuring Distance between Multiple Connected Points Using the Built-In UI
To measure the distance between multiple connected points using the built-in UI, follow these steps:
-
Click the measurement tools icon.
-
Tap Perimeter.
-
Draw lines between the multiple points you want to measure.
Measuring Distance between Multiple Connected Points Programmatically
To measure the distance between multiple connected points programmatically, use the PolylineAnnotation
shape constructor, which takes a measurementScale
property and a measurementPrecision
property as its parameters. For more information on scale and precision, see the guide on configuring measurements.
Configuring Measurements
For more information on configuring measurements, see the guide on configuring measurements.