如何在 laravel 中为 domPDF 设置 customPaper?

How to set customPaper for domPDF in laravel?

这是我在 Controller 中的代码。现在我想设置 CustomPaper 进行打印,因为 A4 尺寸对于 domPDF 中的大宽度文件来说不可移植。

$category = Category::where('id',$request->category_id)->first();
$file = 'Client Ledger Report - '.date('d-m-Y').'.pdf';
$pdf = PDF::loadView('admin.reports.client_statement_report',compact('records','category','type','from','to'));
return $pdf->download($file);

只需在数组变量中写入自定义维度并使用 setPaper() 方法并将其与 PDF::loadView()->setPaper($dimension) 链接起来。 示例:

$category = Category::where('id',$request->category_id)->first();

/* Custom Dimensions */
$dimension= array(0,0,680,920);

$file = 'Client Ledger Report - '.date('d-m-Y').'.pdf';
$pdf = PDF::loadView('admin.reports.client_statement_report',compact('records','category','type','from','to'))->setPaper($dimension);
return $pdf->download($file);