Watermark PDF Guide

Develop your own solution to add image or text watermarks to PDF files by integrating with iLovePDF’s REST API.

Remember that in order to use our Tool Guides, you need to have previous knowledge about the basics to processing a PDF with our REST API. We strongly recommend that you read the Processing a PDF guide before starting this one.

Basic add a watermark

You can add a watermark to your PDF files as shown in this code:

Basic add watermarks

The Watermark tool is composed of 2 different modes that can be configured throught the property mode: text mode adds text watermarks and image mode adds image-based watermarks. The image mode is limited to PNG and JPG format files no bigger than 1Mb.


There is a list of default settings which can be customized, as you will see later:

  • The watermark will be stamped onto all pages
  • The transparency of the watermark is set by default at 100, which is zero transparency, full opacity
  • The watermark will be stamped over the PDF content
  • Its vertical position will be in the middle of the page and its horizontal position will be centered
  • The default font used for numbers will be Arial Unicode with a 14px size
  • Their color will be #000000, Black

These settings and more can be customized as we explain in the next sections.

Advanced add watermarks

Pages for adding a watermark

Pages for adding a watermark

pages has plenty of options to set which pages have to be stamped by a watermark. See these parameters below:

  • all stamps with the watermark. This is the default value.
  • 3-end stamps the third page to the last page will be stamped.
  • 1-3,4-9 stamps pages 1 to 3 and pages 4 to 9 will be stamped with the watermark.
  • -2-end stamps the last 2 pages will be stamped with the watermark.
  • 3-234 stamps pages 3 to 234 will be stamped with the watermark.

Setting watermark opacity

Setting watermark opacity

With transparency you can set the opacity intensity of a watermark for both the text (as shown on the code example) and image files.

Setting watermark layer depth

Setting watermark layer depth

With layer will place your watermark below or above the PDF content. It is set to above by default.

Vertical position of watermark

Vertical position of watermark

vertical_position let you set the vertical position of your watermark at the following places:

  • bottom places the watermark at the bottom end of the page with a default margin.
  • top places the watermark at the top end of the page with a default margin.
  • middle places the watermark at the middle of the page.

Horizontal position of watermark

Horizontal position of watermark

horizontal_position let you set the horizontal position of your watermark at the following places:

  • left places the watermark on the left side of the page with a default margin.
  • right places the watermark on the right side of the page with a default margin.
  • center places the watermark in the center of the page.

Watermark mosaic

Watermark mosaic

If mosaic is set to true, will stamp a 3x3 matrix mosaic of your watermark.

Watermark rotation

Watermark rotation

rotation will stamp your watermark rotated by the specified degrees amount.

Set a watermark font format

Note that this function only works with the text based watermarks. Trying to customize a font with an image will give an error.

Set a watermark font format

font_family, font_style, font_size and font_color are properties to customize text font format. The font_family property changes which font will be used, the font_style property changes the text style such as bold or italic, the font_size property changes the font size, and the font_color property changes the color of the watermark text.