Pro Plan and higher gives you access to the Watermarks functionality.
Watermarks allow you to display any text on top of each (or even) pages of your PDF file – dynamically.
Included Watermark Smart Tags
The plugin comes with several preconfigured dynamic tags.
{fullname}
{username}
{email}
Their names are self-explanatory:
- full name of the person
- their user name
- and email address
Just keep in mind, that if the person who is viewing your PDF files, is not logged in – the values will be replaced with the generic “Not logged in”.
Register new Watermark Smart Tags
There is an API that allows you to register your new custom dynamic tag that will be displayed in the PDF Viewer.
Here is how to do that:
add_filter( 'pdfemb_watermark_var_names', static function( $var_names ) {
$var_names[] = '{year}';
return $var_names;
}, 11 );
add_filter( 'pdfemb_watermark_var_values', static function( $var_values ) {
$var_values[] = date( 'Y' );
return $var_values;
}, 11 );
Code language: PHP (php)
This code snippet will output the current value instead of the {year}
tag. You can put this tag in either plugin settings or inside the watermark
shortcode attribute or the related block option.
The first function registers that tag, and the second one – the replacement value.
Keep in mind, that right now the plugin expects all the registered tags and their values to be registered in the same order. So you should not alter the order of items in the array.