php 使用dompdf无需下载即可查看pdf

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24750527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:27:18  来源:igfitidea点击:

view pdf without downloading using dompdf

phppdfdompdf

提问by OJuice

I generated a PDF using the dompdf library and used this:

我使用 dompdf 库生成了一个 PDF 并使用了这个:

$dompdf->stream('my.pdf',array('Attachment'=>0));

to force the browser to let the user view the PDF before downloading. But it's not working. A Google search isn't bringing up any answers either. Can anyone help?

强制浏览器让用户在下载前查看 PDF。但它不起作用。谷歌搜索也没有给出任何答案。任何人都可以帮忙吗?

回答by Nithyanandhan M

Try using the below code. Let me know are you create data from form or html file data.

尝试使用以下代码。让我知道您是从表单数据还是 html 文件数据创建数据。

$dompdf->stream("dompdf_out.pdf", array("Attachment" => false));

exit(0);

回答by rozanfik

If someone still looking for answer and it's still not resolved, try installing and turning on the PDF Viewer / PDF JS extension in the browser.

如果有人仍在寻找答案但仍未解决,请尝试在浏览器中安装并打开 PDF 查看器/PDF JS 扩展。

After adding parameter array(“Attachment”=>0)or array(“Attachment”=>false)to the streamand still not working. It's because your browser doesn't have a pdf reader available/activated. Installing and activating browser extension like PDF Viewer / PDFJS will force the browser to read and review the pdf.

在将参数array(“Attachment”=>0)或添加array(“Attachment”=>false)流后仍然无法正常工作。这是因为您的浏览器没有可用/激活的 pdf 阅读器。安装并激活 PDF Viewer / PDFJS 等浏览器扩展程序将强制浏览器阅读和查看 pdf。