Enabling snap on measurement tools

Hey, how do I enable snapping on measurement tools like it is done in the demo here?

Webviewer version we’re using is 8.8.0

Hi Adam,

You could refer to this link: Snap to Nearest.
Furthermore, you can download the example code at: Download PDFTron Webviewer.

Using Instance.Core.documentViewer.snapToNearest, you would be able to return the path coordinate within the page that is closest to the queried point. (API - snapToNearest).

That doesn’t really answer my question since the Snap to Nearest snippet you refered to looks and works completely different than what is in the demo.

Hi Adam,

To enable the snap mode in the Webviewer on the measurement tools, you could use

  enableMeasurement: true
}, document.getElementById('viewer')).then(async instance => {
  const { documentViewer } = instance.Core;
  documentViewer.addEventListener('documentLoaded', async () => {
      indicatorColor: "#00a5e4",

There are also other measurement tools and snap modes you could replace in : PDFTron WebViewer Namespace: Tools. You could also checkout the link: Core.AnnotationManager.setSnapDefaultOptions to set default snap options.

Please let us know if this resolve your issue, thank you.

This doesn’t work at all, I get no snapping indicators, nothing. When I turn on measurements none of the tools actually snap, no indicator is displayed.

I checked if its set correctly using the getSnapDefaultOptions() and its set properly. I seem to be missing some check here to enable it

Seems I was missing the fullAPI enabled, after turning it on it works fine. Solved.