8

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?

samuel toh
  • 6,836
  • 21
  • 71
  • 108

1 Answers1

30

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!

Robin Dirksen
  • 3,322
  • 25
  • 40
  • @samueltoh so why are you commenting on older posts? If a user knows the answer he will post it... please don't spam on other post because this is not the same issue. – Robin Dirksen May 02 '17 at 12:31