mPDF Manual – HTML control tags


(mPDF ≥ 3.0)

watermarktext – Set the text to use as a Watermark


<watermarktext  $content [ $alpha ] />

Set the text to use as a Watermark. The watermark is a semi-transparent background printed on each page, used for text such as “DRAFT”. The watermark will be added to each page when the Footer is printed if the variable showWatermark is set to 1 or true



This parameter defines the text to use for the watermark.

$content cannot contain any of the characters: <, >, &, ' or " and must use the appropriate HTML entities e.g. <watermarktext content="Brian&amp;#039;s document" />  It is recommended that you use htmlspecialchars('Content', ENT_QUOTES) for this.

If the text is blank, it will clear the watermark text, so nothing appears.

Default: BLANK


This parameter defines the transparency value (alpha) to use for the watermark: either text or image. The Value should be between '0' and '1'.

Default: '0.2'


Version Description
3.0 The tag was added.


Example #1

$mpdf = new \Mpdf\Mpdf();

$mpdf->showWatermarkText = true;

$mpdf->WriteHTML('<watermarktext content="DRAFT" alpha="0.4" />');

Hello World

See Also

Fork me on GitHub