【问题标题】:Laravel, error when exporting pdf using https protocolLaravel,使用https协议导出pdf时出错
【发布时间】:2021-01-21 02:03:29
【问题描述】:

我有一个收集一系列记录并将它们发送到视图的方法,以导出为 pdf,我使用 Laravel 和 dompdf

 /**
 * @param Request $request
 * @param $id
 * @return mixed
 */
public static function pdfExport(Request $request, $id)
{

    $day = $request->get('day');

    ...
    $group_arr = [];


    $pdf = PDF::loadView('front.cars.pdfExport', compact('group_arr'));

    return $pdf->download('cars.pdf');

}

然后视图是这样的

<style>
    .table{width:100%;margin-bottom:1rem;color:#212529}
</style>

<table>
    <tr>
        <td bgcolor="#415981">
            <img id="definition-image" width="50%" height="50%" src="{{asset('assets/img/logo/logo.png')}}"><br>
        </td>
    </tr>
    <tr>
        <td>TEST PDF
        </td>
    </tr>
</table>

如果我通过 http:// 拨打电话,则此代码适用于我的本地计算机和服务器上,而不是通过 https://

我从 chrome 收到一条错误消息“错误:网络错误”

【问题讨论】:

    标签: php laravel laravel-5 laravel-6 dompdf


    【解决方案1】:

    download() 需要一个文件路径。您可能应该只使用 Storage::download

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-13
      • 2019-11-26
      • 2013-09-12
      • 2018-05-03
      • 1970-01-01
      • 1970-01-01
      • 2010-09-13
      • 1970-01-01
      相关资源
      最近更新 更多