watermarkDocx

watermarkDocx

ADVANCED / PREMIUM BASIC

Inserts a watermark into a Word document.

Description
public void watermarkDocx(String source, String target, String type) throws Exception
public void watermarkDocx(String source, String target, String type, OptionsWatermarkDocx options) throws Exception

This method allows you to insert a watermark image or text in a Word document.

Parameters

source

Path to the Word document.

target

Path to the resulting watermarked document.

type

Watermark type: "text" or "image".

options

Option Type Description
removePreviousWatermarks Boolean If true (default) removes previous watermarks.
scope String header (default) or footer.
section Integer All if not set. Allows adding a watermark per section.

If type is "image":

Option Type Description
image String Path to the watermark image.
height Integer Watermark image height in pixels (optional).
width Integer Watermark image width in pixels (optional).
decolorate Boolean If true (default) decolorates the image.
gain String Optional value to customize decoloration: hexadecimal value.
blacklevel String Optional value to customize decoloration: hexadecimal value.

If type is "text":

Option Type Description
text String The string of text used for watermarking.
textOrientation String Orientation: diagonal (default) or horizontal.
height Integer Watermark text height in pixels (optional).
width Integer Watermark text width in pixels (optional).
font String The font-family. If not set defaults to Calibri.
color String Hexadecimal value or color name (defaults to silver).
opacity Float Decimal number between 0 and 1. If not set defaults to 0.5
Code samples

Example #1

Example #2