Skip to content

Instantly share code, notes, and snippets.

@jakejackson1
Last active September 29, 2018 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jakejackson1/02040fce628eb4750498 to your computer and use it in GitHub Desktop.
Save jakejackson1/02040fce628eb4750498 to your computer and use it in GitHub Desktop.
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