PHPExcel_Writer_Exception在DomPDF.php线34:无法加载PDF渲染库

问题描述 投票:0回答:2

错误导出为PDF。我想作曲家更新和添加的东西到app.php ANF composer.json

 public function exportPDF($request, $orgid)
    {
        /*$pdf = App::make('snappy.pdf.wrapper');
        $pdf->loadHTML('<h1>Test</h1>');
        return $pdf->inline();*/
       $data = User::get()->toArray();
       return Excel::create('itsolutionstuff_example', function($excel) use ($data) {
        $excel->sheet('mySheet', function($sheet) use ($data)
        {
            $sheet->fromArray($data);
        });
       })->download("pdf");
    }
laravel pdf dompdf snappy
2个回答
1
投票

至极的PDF渲染器都设置了?根据该文件,你有3种选择,TCPDF,MPDF和DOMPDF。你必须安装它们中的至少一个。

composer require mpdf/mpdf

然后直接PHPExcel使用它

$renderer = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererPath = dirname(__FILE__).'/../../../libraries/PDF/mPDF6.1'

if (!PHPExcel_Settings::setPdfRenderer(
    $renderer,
    $rendererPath
    )) {
    die('Wrong setup of PDF libraries');
}

0
投票

请评论在DomPDF.php这一行

if (file_exists($pdfRendererClassFile)) {
    require_once $pdfRendererClassFile;
} else {
    throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}

/**  Require DomPDF library */
//$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
//if (file_exists($pdfRendererClassFile)) {
//    require_once $pdfRendererClassFile;
//} else {
//    throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
//}

希望它的作品。

© www.soinside.com 2019 - 2024. All rights reserved.