mPDF Manual – What Else Can I Do

Watermarks

You can add a watermark to the page(s) either text (e.g. DRAFT) and/or a background image.

Set the following before writing the HTML code. NB The watermark is added when writing the footer at the end of a page, so it can be set anytime before ending the page/document.

$mpdf->SetWatermarkText(‘DRAFT’); // Will cope with UTF-8 encoded text

$mpdf->watermark_font = ‘DejaVuSansCondensed’; // Uses default font if left blank

You can alter the transparency values (default = 0.2) using

<?php

$mpdf->watermarkTextAlpha = 0.1;

$mpdf->watermarkImageAlpha = 0.5;

A watermark image is set by default to print on top of the page contents. The opacity setting will alter the appearance of the text behind the image. You can optionally set the watermark to appear behind the page contents using $watermarkImgBehind, but note that the image will be hidden by any background colour specified, including table cells and the page background.

Set the watermark(s) to show using: showWatermarkText or showWatermarkImage

See