保存并下载 PDF
我需要一起做两件事&同时与 DOMPDF 一起使用。
我需要一起做以下事情 - 这可能吗?
//print the pdf file to the screen for saving
$dompdf->stream("pdf_filename_".rand(10,1000).".pdf", array("Attachment" => false));
//save the pdf file on the server
file_put_contents('/home/stsnew/public_html/pdf/file.pdf', $dompdf->output());
如果 $dompdf->stream
和 $dompdf->output()
单独/单独完成,上面的工作正常,但是当我尝试将它们一起运行时,如图所示上面,它只是崩溃了。
任何帮助/建议将不胜感激。
I need to do 2 things together & at the same time with DOMPDF.
I need to do the following together - is this possible?
//print the pdf file to the screen for saving
$dompdf->stream("pdf_filename_".rand(10,1000).".pdf", array("Attachment" => false));
//save the pdf file on the server
file_put_contents('/home/stsnew/public_html/pdf/file.pdf', $dompdf->output());
The above works fine if $dompdf->stream
and $dompdf->output()
are done separately/individually , but when I try to run them together as shown above, it just crashes.
Any help/advice would be really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不先将它们交换为文件,然后将创建的文件流回来?
Why dont you swap them round create the pdf first as a file and then stream the created file back ?
回复晚了但可能会对后续有所帮助。
设置附件 true 或 1
如果您只是寻找下载,则不需要 file_put_contents()
Answering late but might be will help onward.
on set attachment true or 1
No need of file_put_contents() if you are just looking for download