watermarkimage
(mPDF ≥ 3.0)
watermarkimage – Set an image to use as a Watermark
Description
<watermarkimage $src [ $alpha ] [ $size ] [ $position ] />
Set an image to use as a Watermark. The watermark is a semi-transparent background printed on each page, used for text
such as “DRAFT” or a background image. The watermark will be added to each page when the Footer is printed if the
variable showWatermarkImage
is set to 1
or true
.
Parameters
- $src
-
This parameter specifies the image file to use for the watermark. This can be a full URI or use a relative path
- $alpha
-
This parameter defines the transparency value (alpha) to use for the watermark. The Value should be between
'0'
and'1'
.Default:
'0.2'
- $size
-
This parameter takes either a pre-defined string, an integer, or an array of width and height. Defines the size of the watermark.
Values
'D'
: default i.e. original size of image - may depend on img_dpi'P'
: Resize to fit the full page size, keeping aspect ratio'F'
: Resize to fit the print-area (frame) respecting current page margins, keeping aspect ratio- INT: Resize to full page size minus a margin set by this integer in millimeters, keeping aspect ratio
- 2 comma-separated numbers ($width, $height)
e.g
'200,250'
: Specify a size; units in millimeters
Default:
"D"
- $position
-
This parameter takes either a pre-defined string or an array of $x and $y. Defines the position of the watermark on the page.
Values
'P'
: Centred on the whole page area'F'
: Centred on the page print-area (frame) respecting page margins- 2 comma-separated numbers ($x, $y) e.g
'200,250'
: Specify a position; units in millimeters
Default:
"P"
Changelog
Version | Description |
---|---|
3.0 | The tag was added. |
Examples
Example #1
<?php
$mpdf = new \Mpdf\Mpdf();
$mpdf->showWatermarkText = true;
$mpdf->WriteHTML(
'<watermarkimage src="images/background.png" alpha="0.4" size="200,250" />'
);
$mpdf->WriteHTML('
Hello World
');
See Also
- SetWatermarkImage() - PHP equivalent to
<watermarkimage>
- watermarkImageAlpha - Specifies the transparency (alpha value) for the watermark image
- watermarkTextAlpha - Specifies the transparency (alpha value) for the watermark text
- showWatermarkText - Specifies whether or not to show/print the watermark text
- showWatermarkImage - Specifies whether or not to show/print the watermark image
- watermark_font - Specifies the font to use for Watermark text