How to set the page in landscape mode in mpdf?

Kiran picture Kiran · Dec 30, 2013 · Viewed 55.7k times · Source

I am using mpdf library in PHP to create a pdf file from HTML. I need to set the page mode in landscape mode.

Here is the code I am using :

$mpdf=new mPDF('c'); 

$mpdf->WriteHTML($html);
$mpdf->Output();
exit;

However, this is setting the page mode in portrait mode. Any idea, how to set the landscape mode in mpdf ?

Answer

MaGnetas picture MaGnetas · Dec 30, 2013

You can do that by adding -L to your page format. So in our case you'd add another param to your constructor:

$mpdf = new mPDF('c', 'A4-L'); 

More about mPDF constructor params can be found here(deadlink).