生成HTML到PDF,并将生成的PDF上载到存储(laravel)(Dompdf库)

时间:2018-07-28 19:57:22

标签: php laravel pdf dompdf

我想使用storeAs(),但不起作用(Dompdf库)

如何将转换后的PDF文件放入存储区?

$data = ['discription' => 'tifa']; 

$pdf = PDF::loadView('file.viewFile', compact('data'))->storeAs("public/uploud",'filename');

return $pdf->stream("file.pdf");`

1 个答案:

答案 0 :(得分:0)

$data = ['discription'=>'tifa']; 
  $pdf =PDF::loadView('file.viewFile',compact('data'));
    $content = $pdf->output();
       $x= storage_path("app/public/uploud/anyname.pdf");
      file_put_contents($x, $content);

      return $pdf->stream(" anyname.pdf");