# Manually add watermark for printing

**URL:** <https://pdfjs.community/t/manually-add-watermark-for-printing/1934>\
**Category:** Technical Support\
**Created:** [August 11, 2022, 12:11am UTC](https://pdfjs.community/t/manually-add-watermark-for-printing/1934 "2022-08-11T00:11:04Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@andy](https://pdfjs.community/u/andy)\
**Post date:** [August 16, 2022, 6:40pm UTC](https://pdfjs.community/t/manually-add-watermark-for-printing/1934/13 "2022-08-16T18:40:48Z")

</div>

Okay here’s what I have done to solve this:

```javascript
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({})
    }
  }
})

```

---

_[View the full topic](https://pdfjs.community/t/manually-add-watermark-for-printing/1934)._
