Skip to main content

How to add watermarks to PDF files

Watermarks can be added to the foreground or background on each page of a rendered PDF. The watermark/s must be given as PDF files themselves. These watermark PDFs typically have only one page.

The configuration options allow for an array of watermark rules where each rule defines three optional properties (file, pages and position).

The two examples below show how to use the watermarks property.

Simple Example​

This shows how to set a watermark to the foreground on all pages of the PDF. Use the watermark-draft.pdf for this. It is located in the images folder within the comet_xml project.

renderpdf/config.ion (simple watermark)
{
// ...
"watermarks": [
{
"file": "images/watermark-draft.pdf"
}
]
}

Complex Example​

Setting foreground for the first page and for all odd pages (except for the first) and adding at the same time background watermarks from a multipage PDF.

renderpdf/config.ion (different watermarks depending on page number)
{
// ...
"watermarks": [
{
// apply first page of fg-first.pdf to the foreground of page 1
"file": "images/fg-first.pdf",
"pages": "first"
},
{
// apply first page of fg-add.pdf to the foreground of each odd page (except for page 1)
"file": "images/fg-odd.pdf",
"pages": "odd"
},
{
// apply page 1 bg.pdf to the background of page 1, page 2 of bg.pdf to background of page 2 etc.
"file": "images/bg.pdf",
"pages": "all",
"position": "background"
}
]
}

The image below shows how this works on a PDF with three pages and with the objects on the watermarks having 70% transparency.

watermarks-example.webp

Default Watermark​

If no watermark.file is specified, a default PDF will be used. It looks like below:

Default priintcloud watermark