如何获取可在其他Laravel方法中使用的pdf文档-PDF

时间:2019-03-11 22:23:57

标签: php laravel

我正在使用软件包ESC/POS Print,我尝试打印由软件包laravel-dompdf生成的pdf,但我无法使其正常工作,这是向我显示的错误

  

“ message”:“ ImagickException:UnableToOpenBlob   '/storage/app/public/27.pdf'

这是我的代码,改编自github上的example

$pdf = PDF::loadView('miView', compact('data'))
    ->setPaper([0, 0, 420.78, 270.94], 'landscape');
Storage::disk('public')->put($id.'.pdf',$pdf->output());
$pdf = '/storage/app/public/'.$id.'.pdf';
$connector = new NetworkPrintConnector("x.x.x.x", 9100);
$printer = new Printer($connector);
try {
    $pages = ImagickEscposImage::loadPdf($pdf);
    foreach ($pages as $page) {
        $printer->graphics($page);
    }
    $printer -> cut();
    $printer -> close();
} finally {
    $printer -> close();
}

public的配置在filesystems.php中如下

 'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

0 个答案:

没有答案