watermarktext
(mPDF ≥ 3.0)
watermarktext – Set the text to use as a Watermark
Description
<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
.
Parameters
- $content
-
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&#039;s document" />
It is recommended that you usehtmlspecialchars('Content', ENT_QUOTES)
for this.If the text is blank, it will clear the watermark text, so nothing appears.
Default: BLANK
- $alpha
-
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'
Changelog
Version | Description |
---|---|
3.0 | The tag was added. |
Examples
Example #1
<?php
$mpdf = new \Mpdf\Mpdf();
$mpdf->showWatermarkText = true;
$mpdf->WriteHTML('<watermarktext content="DRAFT" alpha="0.4" />');
$mpdf->WriteHTML('
Hello World
');
See Also
- SetWatermarkText() - PHP equivalent to
<watermarktext>
- SetWatermarkImage() - Set an image to use as a Watermark
- 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