PDF Embedder Documentation

Documentation, Reference Materials, and Tutorials for PDF Embedder

Smart Tags for Watermarks

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.

  1. {fullname}
  2. {username}
  3. {email}

Their names are self-explanatory:

  1. full name of the person
  2. their user name
  3. 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.

Still have questions? We’re here to help!

Last Modified: