PDF文件名查看时始终为0

问题描述

我创建了一个功能用户可以转到此链接,并且他可以查看PDF帐单。它正在工作,但名称始终为

0

。这是我的代码

function export_view($account_number_id,$subaccount_number_id){
    $pdf = $this->pdf($account_number_id,$subaccount_number_id);
    $filename = $pdf->name.'.pdf';
    $path = public_path($pdf->path);

    $response = Response::make(file_get_contents($path),200);
    $response->header('Content-Type','application/pdf');
    $response->header('Content-disposition','inline; filename="'.$filename.'"');
    return $response;
}

我也做了手册pdf文件名,看是否是问题所在,但还是一样。当我在本地下载时,名称在那里。我可能做错了什么?

解决方法

我猜您的$this->pdf()方法会从刀片模板渲染pdf吗? 您可以在html标题元标记中设置PDF文档的名称:

<head>
  <title>{{ $invoice->number }}</title>
</head>