mPDF Manual – Paging

Page size & Orientation

Page sizes supported

When declaring an instance of \Mpdf\Mpdf class, you can specify the (default) page size and orientation for the document.

The margins and orientation can be redefined throughout the document whenever you add a new page using AddPage() or <pagebreak>.

It can also be set by CSS using @page.

Examples

Example #1

<?php
$mpdf = new \Mpdf\Mpdf(['format' => 'Legal']);

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

$mpdf->AddPage('L'); // Adds a new page in Landscape orientation
$mpdf->WriteHTML('Hello World');

$mpdf->Output();

Example #2

<?php

// Define a default Landscape page size/format by name
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4-L');

// Define a default page size/format by array - page will be 190mm wide x 236mm height
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'utf-8', [190, 236]);

// Define a default page using all default values except "L" for Landscape orientation
$mpdf = new \Mpdf\Mpdf(['orientation' => 'L']);

See Also

Fork me on GitHub