简体   繁体   English

提供下载pdf或在浏览器中打开的选项

[英]Give an option to download pdf OR open in browser

I'm pretty sure this isn't possible but thought I'd check with you guys. 我很确定这是不可能的,但我想我会和你们一起检查一下。

I've just had a bizarre query from a client who wants to know if it's possible to give the user the option to either download a pdf or open it in their browser. 我刚从客户那里得到了一个奇怪的询问,他想知道是否有可能让用户选择下载pdf或在浏览器中打开它。

They have a thumbnail for the PDF. 他们有PDF的缩略图。 Single click to open it in the browser or double click to download it. 单击以在浏览器中打开它或双击下载它。 I know I can catch the single or double click with jQuery. 我知道我可以用jQuery捕获单击或双击。 I just want to know if it's possible to force the behaviour of the link. 我只是想知道是否可以强制链接的行为。

Thanks 谢谢

This is possible, if for example you are using PHP you can create 2 methods, once will be a simple direct link to the pdf file (if a customer has adobe reader then it will open the pdf in the browser otherwise it will force a download), the other method would always force a download. 这是可能的,例如,如果您使用PHP,您可以创建2个方法,一次将是pdf文件的简单直接链接(如果客户有adobe reader,那么它将在浏览器中打开pdf,否则将强制下载),另一种方法总是强制下载。

You can find a PHP force file download example here: How to force download of a file? 你可以在这里找到一个PHP强制文件下载示例: 如何强制下载文件?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM