Disable context menu in PSPDFKit

There might be cases where you want to disable right click inside the PSPDFKit iframe. You can do this by using the following code:

PSPDFKit.load(options).then(instance => {
  // Disable the contextmenu
  instance.contentDocument.addEventListener('contextmenu', event => event.preventDefault())
})

As you can see above we have to use instance.contentDocument to access iframe’s document object.

This has been tested with PSPDFKit for Web 2020.1.2