Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A sample PDF template using the HTML header and footer tags
<?php
/**
* Template Name: Example Header and Footer 2
* Version: 0.1
* Description: A sample PDF template using the HTML header and footer tags
* 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;
}
?>
<!-- Any PDF CSS styles can be placed in here -->
<style>
table.header {
border-bottom: 1px solid #000000;
vertical-align: bottom;
font-family: serif;
font-size: 9pt;
color: #000088;
width: 100%;
}
.footer {
text-align: center;
}
</style>
<!-- register header and footer -->
<htmlpageheader name="myHeader">
<table class="header">
<tr>
<td width="50%">Main Header</td>
<td width="50%" style="text-align: right;">Logo</td>
</tr>
</table>
</htmlpageheader>
<!-- Header hack to turn it off on the chosen page -->
<htmlpageheader name="blank">&nbsp;</htmlpageheader>
<htmlpagefooter name="myFooter">
<div class="footer">
{PAGENO}/{nbpg}
</div>
</htmlpagefooter>
<!-- Include our header and footer -->
<sethtmlpageheader name="myHeader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myFooter" value="on" />
<!-- Write PDF body -->
<h2>Header</h2>
<p>Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </p>
<pagebreak />
<!-- Hack for header so nothing is displayed on this page -->
<sethtmlpageheader value="on" show-this-page="1" name="blank" />
<h2>Header</h2>
<p>Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </p>
<pagebreak />
<sethtmlpageheader name="myHeader" value="on" show-this-page="1" />
<sethtmlpagefooter value="off" />
<h2>Header</h2>
<p>Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </p>
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.