I’m creating a set of invoice/quote templates for sharing with the community and I’d really like to use one of the mPDF functions (watermark) within the invoice overdue and paid templates.
$mpdf->SetWatermarkText('PAID');
When I use it in the template it breaks it. I’ve tried it with and without enclosing it in <?php ?> but without success.
I know that this is quite old but i have a solution for the watermark text.
Since i was looking also a way to display a watermark on the invoice i started writing the css code and i found out that mPdf doesnt support rgba(r,g,b,a) color in text. No matter what you put as an alpha channel it is always set to 1 => full opacity.
While searching the mPdf documents i found out that it has a function SetWaterMarkText() which suddenly we cant use from our php. But instead of that mPdf also has the “watermarktext” which we can use directly in our php code like this <watermarktext content="Text as watermark" alpha="0.4" />. For this to work we also need to edit the mpdf_helper.php file and add the line $mpdf->showWatermarkText = true; before the WriteHTML() call.
The above will add a 45 degrees rotated text in the whole page as a watermark. Unfortunately this wont work if someone wants to add a watermark at a specific position in the pdf.
I hope that this will help someone else also and give some ideas on the developers to add in the next version, something like “Show Invoice Watermark” and “Watermark Text :” in the invoice settings.