Watermarks for a document are stored in a json file. Like annotations, the file will be documentkey + suffix, e.g., 6-Pages-1.tif.watermarks.json.

The watermarks.json file is a list of json objects, so it has the format:

[ { myJsonData }, { myOtherJsonData }]

Watermark properties

Each individual watermark is a json object. Each will have the following properties:

Property Type Description
Transparency Boolean

If true, the watermark will be transparent, if false, it will be a solid color.

adminCreated Boolean

If false, any user can manage any aspect of the watermark. If true, admin restrictions will apply (as described below).

Text string

This is the text that will appear on the watermark. Multiline watermarks are supported. This is done under the hood in the watermarks dialog, but if a user is manually entering json, they should enter a newline character (“\n”) where a line break should be.

allPages Boolean

If this is set, the watermark will appear on every page of a document.

Pages array of page indices, zero-indexed

For instance, to place a watermark on only page one, this property would contain [ 0 ]. This is a key difference between watermarks and annotations. Watermarks are intended to repeat across pages, so an identical watermark will have multiple pages it applies to.

widthAtTenPx integer

This is a read-only value used by VirtualViewer to calculate the dimensions of the watermark, representing how wide the watermark is when the font is 10 pixels high.

Stretch double

This defines how far across the page the watermark will stretch. Set to 1.0, the watermark will go across 100% of the page (minus some margin space). Set to 0.5, 50% of the page. The UI allows only a small set of percentages. Diagonal watermarks will always stretch 100% across the diagonal.

Format json sub-object

A json sub-object that has font and color information as follows:

  • font: A font name, for instance “Arial”
  • color: We currently support only one color, so "000000" would be stored here.
Position json sub-object

This is another sub-json object, that defines where the watermark will be placed on the page. There are two defining properties in here: the vertical placement of the watermark (top of the page, middle of the page, or the bottom of the page) and the direction of the text. While these options may open up further, the direction options are currently left-to-right text or diagonal text. The two options combine so that, for instance, top vertical lacement & diagonal direction produce a watermark stretching from the top-left to bottom-right corner–while bottom vertical placement & diagonal direction will go from bottom-left to top-right:

  • vertical: Use 0 for top, 1 for center, and 2 for bottom.
  • direction: Use 0 for left-to-right text, and 2 for diagonal text.

Watermark.json file sample

Below is a sample of what a watermark.json file might look like:

[{"widthAtTenPx":19,
  "transparency":true,
  "adminCreated":false,
  "text":"bugs",
  "allPage s":true,
  "pages":[],
  "stretchPercent":0.5,
  "format":{"font":"Times New Roman",
            "color":"000000"},
  "position":{"vertical":0,
  "direction":0}
  },
 {"widthAtTenPx":86,
  "transparency":true,
  "adminCreated":false,
  "text":"second%20watermark",
  "allPages":false,
  "pages":[0],
  "stretchPercent":1,
  "format":{"font":"Times New Roman",
            "color":"000000"},
  "position":{"vertical":2,
              "direction":2}
  },
 {"widthAtTenPx":62,
  "transparency":false,
  "adminCreated":false,
  "text":"some text",
  "allPages":false,
  "pages":[0],
  "stretchPercent":1,
  "format":{"font":
            "Times New Roman",
  "color":"000000"},
  "position":{"vertical":2,
              "direction":0}
  }
]