Make watermark only visible when printing mPDF

Hi everyone,

I don’t know if this is posted in the right place but the system is built with php so…

The title says it all, i need to make a invoice with a watermark that only shows when the person is printing out the invoice, The watermark must show “Computer generated tax invoice” for legal reasons.

I have search all around but have not found anything, i have also checked in the documentation for anything that will help and the any thing i have found is SetVisibility() but it only accepts visibility parameters, it would be cool if it also accepted a function to only show when printing like the watermark function.

I don’t have a problem making the watermark itself.

Does anyone have an idea on how to do this?
the version of mPDF is 5.7 if you need any other information please let me know and thanks in advanced.
Have a great day :slight_smile:

Hi all,

If there is someone that will need this in the future here is a solution:

edit the file mpdf.php and add the following line to the start of the functions (please note that this will be on all document made with mPDF)
The functions:

function watermark()
function watermarkImg()


and add this line to the bottom of the same functions


One thing to note is you can wrap the two line of code in a if statement and add a parameter in the functions parameters so that way you can use mPDF without any problems and only when you need to use print only watermarks you can pass a parameter.

Thank you for coming back and posting your answer.

No problem :smiley: