mPDF Manual – Paging

Double-sided documents

Odd/Even pages and margins

mPDF can use alternating margins for ODD and EVEN pages (e.g. for DOUBLE-SIDED printing). If $mirrorMargins ($useOddEven in mPDF < 4.0) is set to TRUE or 1 before adding the first page, the document will mirror the left and right margin values on ODD and EVEN pages i.e. they become inner and outer margins. (this is automatically reversed for RTL languages).

NB Headers and footers use the ODD pages as default if this is not used.

The first page in a document will be ODD i.e. page number 1, and will appear as a RIGHT page in a LTR document (or LEFT page in a RTL document)

Examples

Example #1

<?php

// Define a document with default left-margin=30 and right-margin=10

$mpdf = new mPDF('','', 0, '', 30, 10);

$mpdf->mirroMargins = true;

$mpdf->WriteHTML('
Hallo World
');

$mpdf->AddPage();

// Now the right-margin (inner margin on page 2) = 30

$mpdf->WriteHTML('
Hallo World
');

$mpdf->Output();

?>