使用dompdf在新标签页中打开PDF [英] Open PDF in a new tab using dompdf

查看:118
本文介绍了使用dompdf在新标签页中打开PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用dompdf生成pdf,如何在浏览器的新标签页中打开pdf?就像,我单击PDF的链接,它应该在新标签中打开,而不是自动保存。我想让用户选择先查看文件后再保存。我怎么做?

Im trying to generate pdf using dompdf, how can I open the pdf in a new tab in a browser? Like, I Click A link for the PDF and it should open in a new tab, not save it automatically. I want to give the user a choice to save the file after seeing it first. how do i do that?

无论何时我在文件末尾使用$ pdf-> output,它都不会改变任何事情,该文件仍会自动下载。
请帮忙。谢谢。

whenever i use $pdf->output at the end of the file, it does not change a thing, the file is still downloaded automatically. please help. thanks.

推荐答案

在浏览器中下载或查看PDF取决于两个因素。一种是您的浏览器设置,但我们无法控制。第二个是dompdf如何将PDF呈现给浏览器。您可以使用 $ dompdf-> stream('my.pdf',array('Attachment'=> 0)); 告诉dompdf提供直接查看的PDF。

Whether a PDF is downloaded or viewed in the browser depends on a couple of factors. One is your browser settings, but we have no control there. The second is how dompdf present the PDF to the browser. You can tell dompdf to offer the PDF for direct viewing using $dompdf->stream('my.pdf',array('Attachment'=>0));.

至于在新标签页中打开。这取决于您如何生成PDF。但是,它是提供带有target属性的链接的最简单方法。

As far as opening in a new tab. That depends on how you are generating the PDF. But the simplest way it to provide a link with a target attribute.

这篇关于使用dompdf在新标签页中打开PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆