laravel 如何在laravel-dompdf中设置景观?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41230915/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to setting landscape in laravel-dompdf?
提问by samuel toh
I get reference from here : https://github.com/barryvdh/laravel-dompdf
我从这里得到参考: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 :
我尝试\config\dompdf
像这样设置风景:
'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?
有没有人可以帮助我?
回答by Robin Dirksen
You can use the option setPaper
option:
您可以使用选项setPaper
选项:
public function listdata()
{
$pdf = PDF::loadView('pdf.test_pdf')->setPaper('a4', 'landscape');
return $pdf->stream('test_pdf.pdf');
}
Hope this works!
希望这有效!