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.


Example #1

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

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

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


Example #2


// 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' => [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