【发布时间】:2015-06-30 12:52:25
【问题描述】:
我正在使用 PDF Snappy 从 Laravel 4 中的视图生成 PDF 文件。
我可以使用 download() 毫无问题地使用此代码,并且文件已生成并且我可以保存它:
$pdf = PDFSnappy::loadView($pdfView, $dataForPDF);
return $pdf->download( 'invoice.pdf' );
但是,当我尝试将 save() 与此代码一起使用时:
$pathToFile = "invoices/2015/full/invoice.pdf";
$pdf = PDFSnappy::loadView($pdfView, $dataForPDF);
return $pdf->save( $pathToFile );
我收到此错误消息:
Object of class Barryvdh\\Snappy\\PdfWrapper could not be converted to string
如果我尝试这样的事情:
$pathToFile = url() . '/' . "invoices/2015/full/invoice.pdf";
$pdf = PDFSnappy::loadView($pdfView, $dataForPDF);
return $pdf->save( $pathToFile );
我收到此错误消息:
The output file's directory http://laravel.dev/invoices/2015/full/ could not be created.
我在 Windows 上使用 WAMP,这可能是个问题吗?
如何将文件保存到 invoices/2015/full/ 内 Laravel 中的 /public 文件夹中?
【问题讨论】:
标签: php laravel laravel-4 pdf-generation wkhtmltopdf