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

<?php

// Define a document with default left-margin=30 and right-margin=10
$mpdf = new \Mpdf\Mpdf([
	'margin_top' => 0,
	'margin_left' => 30,
	'margin_right' => 10,
	'mirrorMargins' => true
]);

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

$mpdf->AddPage();

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

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

$mpdf->Output();

Fork me on GitHub