Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A sample PDF template showing off the text and image watermarks. Note: you will need to save an image called `gravityformspdfextended.jpg` to `images`.
<?php
/**
* Template Name: Example Watermarks
* Version: 0.1
* Description: A sample PDF template showing off the text and image watermarks
* Author: Gravity PDF
* Group: Example
* License: GPLv2
* Required PDF Version: 4.0
*/
/* Prevent direct access to the template (always good to include this) */
if ( ! class_exists( 'GFForms' ) ) {
return;
}
?>
<!-- Basic Text Watermark -->
<watermarktext content="PRIVATE" />
<pagebreak />
<!-- Text Watermark with alpha transparency -->
<watermarktext content="PRIVATE" alpha="0.1" />
<pagebreak />
<!-- Text Watermark with special characters -->
<watermarktext content="<?php echo htmlspecialchars( '<CONFIDENTIAL>', ENT_QUOTES ); ?>" />
<pagebreak />
<!-- Disable Text Watermark -->
<watermarktext content="" />
<pagebreak />
<!-- Basic Image Watermark -->
<watermarkimage src="<?= __DIR__ ?>/images/gravityformspdfextended.jpg" />
<pagebreak />
<!-- Image watermark with 50% transparency -->
<watermarkimage src="<?= __DIR__ ?>/images/gravityformspdfextended.jpg" alpha="0.5" />
<pagebreak />
<!-- Image watermark resized to fit the full page -->
<watermarkimage src="<?= __DIR__ ?>/images/gravityformspdfextended.jpg" size="P" />
<pagebreak />
<!-- Image watermark with default size positioned 10mm x 10mm from the top left corner -->
<watermarkimage src="<?= __DIR__ ?>/images/gravityformspdfextended.jpg" position="10,10" />
<pagebreak />
<!-- Image watermark resized to 50x50mm image -->
<watermarkimage src="<?= __DIR__ ?>/images/gravityformspdfextended.jpg" size="50,50" />
<pagebreak />
<!-- Disable image watermark -->
<watermarkimage src="" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.