使用Dompdf在pdf文件中存储数据:
这个函数可以正常工作:
$pdf = 'App::make('dompdf.wrapper');
$pdf->loadHTML('<h1>Test</h1> ');
return $pdf->stream();
现在,当试着
$pdf = 'App::make('dompdf.wrapper');
$pdf->loadHTML('<h1>Test</h1> ');
file_put_contents("test.pdf", $pdf->output());
得到错误:
file_put_contents(test.pdf): failed to open stream: Permission denied
我是否需要创建一个额外的文件夹来保存文件或其他什么?
Tnx, p
要保存生成的pdf
到文件中,使用output()
,即:
$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>hello world</h1>');
$output = $dompdf->output();
file_put_contents('filename.pdf', $output);
此解决问题:
return PDF::loadHTML('<h1>Test</h1> ')->save('path-/my_stored_file.pdf');
这个问题帮助:
dompdf:加载HTML文件渲染,不't工作
Tnx,P
试试这个
$pdf->load_html('<h1>Test</h1>');
$pdf->render();
$pdf->stream("data.pdf");
您应该检查文件夹的权限。(0777)输入图片描述
$pdf->load_html('<h1>Test</h1>');
$pdf->render();
$output = $pdf->output();
file_put_contents('./historialCartera/prueba.pdf', $output);
输入图片描述