Okay here’s what I have done to solve this:
instance.iframeWindow.addEventListener("visibilityChanged", (event) => {
if (event.detail.element === "printModal") {
if (event.detail.isVisible) {
// Draw diagonal watermark in middle of the document
documentViewer.setWatermark({
diagonal: {
fontSize: 55,
fontFamily: 'sans-serif',
color: 'red',
opacity: 40,
text: 'Custom watermark text'
}
})
} else {
// Clear the watermark
documentViewer.setWatermark({})
}
}
})