Skip to content

Instantly share code, notes, and snippets.

@jakejackson1
Last active March 18, 2018 10:09
Show Gist options
  • Save jakejackson1/7d62b713e51f8e956a91 to your computer and use it in GitHub Desktop.
Save jakejackson1/7d62b713e51f8e956a91 to your computer and use it in GitHub Desktop.
A sample PDF template using the @page header and footer
<?php
/**
* Template Name: Example Header and Footer
* Version: 0.1
* Description: A sample PDF template using the @page header and footer
* 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>
@page {
header: html_myHeader;
footer: html_myFooter;
}
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>
<htmlpagefooter name="myFooter">
<div class="footer">
{PAGENO}/{nbpg}
</div>
</htmlpagefooter>
<!-- 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 />
<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 />
<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