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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:57:36  来源:igfitidea点击:

How to setting landscape in laravel-dompdf?

phplaravellaravel-5.3dompdf

提问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\dompdflike 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 setPaperoption:

您可以使用选项setPaper选项:

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

Hope this works!

希望这有效!