Skip to main content
Version: 3

Example of Adding Custom Page Sizes to PDF Templates

Change Document Size

The plugin ships with a number of PDF templates showing off the features of mPDF. These can be found in your PDF_EXTENDED_TEMPLATES directory.

Overview

To easily switch between custom PDF templates change the template query string parameter to the template name when viewing a PDF via your admin area.
Template Name: example-different-page-size_08.phpExample URL: https://test.com/?gf_pdf=1&fid=3&lid=40&template=example-different-page-size_08.php

mPDF allows the document size and layout to be changes on a per-page basis, giving you finite control over the output of your PDF document.

Pagebreaks can be controlled using the <pagebreak> tag or via Named @page elements. However the simplest technique is to use the <pagebreak> tag.

Download Example PDF

Example

<!-- set the next page to A6 -->
<pagebreak sheet-size="A6" />

<!-- set the next page using a custom size -->
<pagebreak sheet-size="70mm 150mm" />

<!-- set the next page to landscape -->
<pagebreak orientation="landscape" />

<!-- combine the sheet size and orientation -->
<pagebreak sheet-size="A4" orientation="landscape" />

While the examples are basic, the <pagebreak> element attributes can be complex so we advise you read the mPDF documentation before using it.