Skip to content

Instantly share code, notes, and snippets.

@jakejackson1
Last active March 31, 2023 04:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakejackson1/2822bd311df289684840 to your computer and use it in GitHub Desktop.
Save jakejackson1/2822bd311df289684840 to your computer and use it in GitHub Desktop.
A simple Hello World template for Gravity PDF with additional styling
<?php
/**
* Template Name: Hello World
* Version: 0.1
* Description: A basic "Hello World" PDF template showing custom PDF templates in action
* Author: Jake Jackson
* Author URI: https://gravitypdf.com
* Group: Sol System
* License: GPLv2
* Required PDF Version: 4.0
* Tags: space, solar system, getting started
*/
/* Prevent direct access to the template (always good to include this) */
if ( ! class_exists( 'GFForms' ) ) {
return;
}
/**
* All Gravity PDF v4/v5/v6 templates have access to the following variables:
*
* @var array $form The current Gravity Form array
* @var array $entry The raw entry data
* @var array $form_data The processed entry data stored in an array
* @var object $settings The current PDF configuration
* @var array $fields An array of Gravity Form fields which can be accessed with their ID number
* @var array $config The initialised template config class – eg. /config/zadani.php
*/
?>
<!-- Any PDF CSS styles can be placed in the style tag below -->
<style>
h1 {
text-align: center;
text-transform: uppercase;
color: #a62828;
border-bottom: 1px solid #999;
}
</style>
<h1>Hello World</h1>
@jakejackson1
Copy link
Author

Hi how to make auto page break with this template? also how to set content area (body, header & footer)

@jasimp sorry for the delay. I've been out of the office and only have just returned.

See our documentation for how to control the Header / Footer content of a PDF: https://docs.gravitypdf.com/v6/developers/pdf-features/headers-and-footers

The body content of the PDF will be whatever standard HTML you output in your custom template.

Page breaks will automatically occur once the body content reaches the bottom of the page content area. You can also add manual page breaks if needed: https://docs.gravitypdf.com/v6/developers/pdf-features/pagebreaks

@jakejackson1
Copy link
Author

Hello,

When Gravity PDF plugin has an update, will any edits we make on the core templates be overwritten by the update? Will the templates we create also be overwritten or deleted due to a Gravity PDF plugin update?

Thanks.

@WebEngineerGuy If you follow our development guide for modifying core templates, then no. Your changes won't be overridden or deleted during a plugin update: https://docs.gravitypdf.com/v6/developers/template-hierarchy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment