如何在iframe中显示PDF? [英] How to show PDF in iframe ?

查看:1547
本文介绍了如何在iframe中显示PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

string filePath = Server.MapPath("admit.pdf");
            myframe.Attributes.Add("src", "" + filePath.ToString());



错误:
Firefox不知道如何打开该地址,因为protocol(c)与任何程序都没有关联.


请告诉我如何解决此问题以在IFrame中显示pdf文件?



Error :
Firefox doesn''t know how to open this address, because the protocol(c) isn''t associated with any program.


Please tell me how to solve this problem to show the pdf file in IFrame ?

推荐答案

PDF不是标准的W3文件类型;它通过相应的插件(在本例中为Adobe插件)显示在浏览器中.用户需要安装插件才能正常工作( http://www.adobe.com/downloads/ [ ^ ]).

您的Web应用程序不应依赖于此.您应提供对该文件的访问权限,浏览器应建议用户下载该文件或使用用户选择的某些应用程序打开该文件(与浏览器未知的任何其他文件类型一样).如果浏览器的设置对此内容类型具有默认操作,则可以通过插件或其他方式在浏览器中查看.

作为第一种选择,我宁愿做最简单的事情:
PDF is not a standard W3 file type; it is shown in the browser through the corresponding plug-in (an Adobe plug-in, in this case). The user needs to install the plug-in to have it working (http://www.adobe.com/downloads/[^]).

Your Web application should not rely on this. You should provide the access to the file, and the browser should suggest the user to download it or open with some application chosen by the user (as any other file type unknown to the browser). If the browser''s settings have some default action for this content type, if can view it in browser, via a plug-in or otherwise.

As the first option, I would rather do the simplest possible thing:
<a href="admit.pdf">Admit.PDF</a>



在这种情况下,任何合理的浏览器的行为都将与我上面所述的完全相同.

—SA



In this case, any reasonable browser will behave exactly as I described above.

—SA


这篇关于如何在iframe中显示PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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