-
-
Save jakejackson1/2822bd311df289684840 to your computer and use it in GitHub Desktop.
<?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> |
any PDF CSS is a bit of a stretch for current css standards. Grid definitely not adopted. uses mPDF to write the PDF file.
Correct, modern CSS like Grid of Flexbox is not supported in mPDF. The comment block on line 22 specifically references PDF CSS styles, and this private Gist is only linked to on a page in our documentation that includes additional context/links about limitations of the PDF engine. When looked at in that regard "PDF CSS" shouldn't be misleading/suggest modern CSS is 100% supported, but I thank you for the feedback.
Yes, I'm one of Gravity PDF's developer. Floats or tables (yeah, I know...) is how you'd need to do layout in your PDF templates.
No stress at all! Like you, I'd love for an open source PHP HTML to PDF library that supported modern CSS. Maybe one day...
Is there any update for developers about how to create PDF? I mean modern CSS etc? Or still floats and tables are neccessary to use?
@drozumek nope. Still tables and floats. The underlying tech Gravity PDF uses is the open source library mPDF and contributions are welcome!
I am still learning how to create my own template. Do you have an idea for a nice development workflow to see the effects of changes to my custom template directly in a PDF? Do I have to save a form every time and generate it as a PDF or is there a more elegant way to do this (maybe Wordpress CLI)?
When asked I didn't know the PDF file is regenerated on a tab reload with the updated template. In conjunction with the HTML-view, the browsers object inspector and some of the template hooks it was really easy and fun. Thanks!
Hi
how to make auto page break with this template?
also how to set content area (body, header & footer)
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.
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
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
any PDF CSS is a bit of a stretch for current css standards. Grid definitely not adopted. uses mPDF to write the PDF file.