watermarkDocx

watermarkDocx

ADVANCED / PREMIUM BASIC

Inserts a watermark into a Word document.

Description
public watermarkDocx (string $source, string $target, [string $type, array $options])

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

The possible keys and values are (required options are shown with yellow background):

Key Type Description
section int All if not set. Allows adding a watermark per section.
remove_previous_watermarks bool If true (default) removes previous watermarks.

If type is 'image':

Key Type Description
image string Path to the watermark image.
height int Watermark image height in pixels (optional).
width int Watermark image width in pixels (optional).
decolorate bool 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':

Key Type Description
text string The string of text used for watermarking.
text_orientation string Orientation: diagonal (default) or horizontal.
height int Watermark text height in pixels (optional).
width int 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
add_vshapetype_tag bool If true (default as false) adds a v:shapetype tag to force LibreOffice to display the text watermark.
Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like: