繁体   English   中英

Laravel dompdf 空白 pdf

[英]Laravel dompdf blank pdf

我正在使用 laravel-dompdf 为我的应用程序生成 PDF 报告。 我在同一个应用程序中使用过它,它工作正常......这个 model 它正在生成一个空白 PDF。

查询正在返回数据,所以这不是问题......我的代码:

public function serviceReport(Request $request){
    $title = 'Servicio';

    $meta = [ 
        'N°' => '1'
    ];

    $query = Service::query();

    $query->select(\DB::raw('services.id as serviceid'), \DB::raw('customers.name as customername'))
        ->leftJoin('customers', 'customers.id', '=', 'services.id_customers')
        ->where('services.id', '=', '1')
        ->get();

    $columns = [
        'Servicio' => 'serviceid',
        'Cliente' => 'customername'
    ];

    return PdfReport::of($title, $meta, $query, $columns)
    ->limit(20)
    ->download('filename');
}

我的 vuejs function:

getReport(){
    var name = 'Reporte Servicio.pdf';
    this.service.post('/api/service/report', {responseType: 'blob'})
    .then((response) => {

        var fileURL = window.URL.createObjectURL(new Blob([response.data]));

        var fileLink = document.createElement('a');

        fileLink.href = fileURL;

        fileLink.setAttribute('download', name);

        document.body.appendChild(fileLink);

        fileLink.click();
    })
    .catch(function (error) {
        console.log(error);
    })
},

PDF:

在此处输入图像描述

问题是vForm。 我已更改为正常的 axios 请求并开始工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM