Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setting landscape in laravel-dompdf?

I get reference from here : https://github.com/barryvdh/laravel-dompdf

My controller code is like this :

public function listdata()
{
    $pdf=PDF::loadView('pdf.test_pdf');
    return $pdf->stream('test_pdf.pdf');
}

I try setting landscape in \config\dompdf like this :

'show_warnings' => false,   // Throw an Exception on warnings from dompdf
'orientation' => 'landscape',

But, it's not working. The result is still portrait

Is there any people who can help me?

like image 892
samuel toh Avatar asked Dec 19 '16 21:12

samuel toh


Video Answer


1 Answers

You can use the option setPaper option:

public function listdata()
{
    $pdf = PDF::loadView('pdf.test_pdf')->setPaper('a4', 'landscape');
    return $pdf->stream('test_pdf.pdf');
}

Hope this works!

like image 151
Robin Dirksen Avatar answered Sep 22 '22 16:09

Robin Dirksen