Articles on: Tutorials

Insert a watermark dynamically

Insert a watermark dynamically



It exists 2 solutions:
- Insert a watermark as a Carbone tag on your template. It is possible to change the color, orientation, and opacity of the watermark. (e.g. Example 1 with Libre Office, Example 2 with MS Word)
- Insert a watermark as a PDF rendering option when requesting Carbone Render API. The watermark will be green, it is not possible to change the color, orientation, and opacity. (e.g. Example 3)

Example 1 with Libre office



The goal is to insert a watermark as a Carbone tag on the template.
On Libre Office,
From the menu, click Format > Watermark.
Insert the Carbone tag on the text field.
Then, customize the watermark by setting the font, angle, size, colors, and transparency.

Watermark options on Libreoffice

During rendering, if the JSON dataset has the property watermark , such as { "watermark": "carbone.io" }, it will print the watermark with the carbone.io value. If the attribute watermark is not included on the JSON dataset, it will print nothing.


Example 2 with MS Word



The goal is to insert a watermark as a Carbone tag on the template.

On the Design tab, select Watermark.
In the Insert Watermark dialog, select Text and type a Carbone tag, such as {d.watermark}.
Then, customize the watermark by setting the font, layout, size, colors, and orientation.


Watermark options on MS Word

During rendering, if the JSON dataset has the property watermark , such as { "watermark": "carbone.io" }, it will print the watermark with the carbone.io value. If the attribute watermark is not included on the JSON dataset, it will print nothing.

Example 3 PDF Rendering option



This example is available only for Carbone Render API or Carbone On-premise.

When PDF are generated (POST /render/:templateID), rendering options can be passed to the request to create a watermark.
The body request should include a convertTo object with a child attribute formatName set to pdf and formatOptions with options:
{
  convertTo : {
    formatName    : 'pdf',
    formatOptions: {
      Watermark : 'carbone.io'
    }
  }
}

It will create a green watermark, such as:


More PDF rendering options are available, click to learn more.

Updated on: 09/09/2022

Was this article helpful?

Share your feedback

Cancel

Thank you!