Set watermark before download file

How I can add watermark before download file? Can you explain it ? Thanks!

Hi there,

You can use the setWatermark API to add a watermark to the document.
Please see our guide for reference:

Best regards,
Kevin Kim

how can i catch before download event?

Hi there,

I presume you mean to apply the watermark right before the download event.

You could override the download button in our UI to apply the watermark and then download the pdf.

For instance:

instance.UI.updateElement('downloadButton', {
  onClick: async () => {
    instance.Core.documentViewer.setWatermark({
      // Draw diagonal watermark in middle of the document
      diagonal: {
        fontSize: 25, // or even smaller size
        fontFamily: 'sans-serif',
        color: 'red',
        opacity: 50, // from 0 to 100
        text: 'Watermark'
      },

      // Draw header watermark
      header: {
        fontSize: 10,
        fontFamily: 'sans-serif',
        color: 'red',
        opacity: 70,
        left: 'left watermark',
        center: 'center watermark',
        right: ''
      }
    });
    await instance.UI.downloadPdf()
  }
});

Best regards,
Kevin Kim