Allow custom PDF watermark text

December 11, 2018
Joost de Keijzer

I’d like to add a “Draft” watermark to the pdf invoices.

The html variant uses the `sliced_get_invoice_watermark` function which has a filter to add extra watermark text.

The PDF does not use this function and has no option to add a custom watermark text.

Please also use `sliced_get_invoice_watermark` for the PDF watermark text, eg:

“`
public static function set_watermark( $id = 0, $mpdf ) {

if( $text = sliced_get_invoice_watermark( $id ) ) {
//watermarks
$mpdf->SetWatermarkText( $text );
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = ‘Helvetica’;
$mpdf->watermarkTextAlpha = 0.07;
$mpdf->SetDisplayMode(‘fullpage’);
}

return $mpdf;

}
“`

1 Comment. Leave new

Sliced Invoices
December 11, 2018 8:07 pm

This is not necessary. You can use the hook ‘sliced_pdf_init’ which passes the $mpdf object as it’s only argument. Example:

add_action( 'sliced_pdf_init', 'sliced_pdf_html_custom_params', 10, 1 );
function sliced_pdf_html_custom_params( $mpdf ) {
	$mpdf->SetWatermarkText( 'draft' );
}

Leave a Reply

Your email address will not be published.