在HTML页面中嵌入本地PDF [英] Embed a local PDF in HTML page

查看:1454
本文介绍了在HTML页面中嵌入本地PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:
在远程服务器上运行的Web应用程序显示PDF。 PDF文档存储在客户端PC上(位置已知)。

有什么方法可以将PDF嵌入到带有本地路径的HTML页面中?



ps:
到目前为止,我尝试过使用object,embed和iframe,但没有成功。

I尝试使用file://,file:///,没有,带斜杠和反斜线的URL,没有任何作用。如果在浏览器URL中直接打开它,它就会工作,而不是通过嵌入。

解决方案

不久前我有一个类似的问题,没有办法直接将任何类型的本地文件嵌入到网页中。



四种解决方案(既不那么好):


  1. 使用 http://djproject.sourceforge.net/ns/ (或尝试使用默认查看器打开文件)。这个小程序可以嵌入到网页中。

  2. 在HTML和服务器端语言中,建立一个上传脚本,将客户端计算机上的PDF上传到然后通过另一页显示此PDF。 使用PDF嵌入代码和文件://开始创建一个html页面(给绝对路径)。使用标题来表明此页面将被下载而不是查看。然后,用户可以在浏览器中打开该文件,以便查看PDF(因为该网页是本地的,来自相同的IP地址)。这可以在IE浏览器,Opera,但不是Chrome,FF或Safari。 C ++。使用已知的URL将PDF阅读器作为activex嵌入到PDF中(可将其存储在静态字符数组中,以便服务器端脚本可以直接编辑exe以将PDF路径放入其中)。然后,我会使用浏览器组件在屏幕上嵌入PDF旁边的浏览器,从而在PDF旁边显示您的在线网页,即使其中一个不能嵌入到其他页面中也是如此。 b $ b

通过 http://yumyar.com


Situation: Web application running on a remote server is displaying PDFs. PDF document is stored on client's PC (location is known).

Is there any way to embed that PDF into HTML page with local path?

p.s.: So far i tried "object", "embed" and "iframe" and with no success.

I tried with file://, file:///, and without, URL with slashes and backslashes and nothing works. It works if opened directy in browser URL, just not by embedding

解决方案

I had a similar problem a while ago, unfortunately there is no way of directly embedding a local file of any kind into a webpage.

Four solutions (neither that nice):

  1. Build a signed (so it can access the client's computer) java app with an embedded PDF viewer using http://djproject.sourceforge.net/ns/ (or try to open the file using the default viewer). This applet could then be embedded in the webpage.

  2. In HTML and a server side language, build an upload script to upload the PDF on the client's computer to a temp dir on your server, then display this PDF through another page.

  3. Create an html page with the PDF embed code and the file:// at the beginning (giving an absolute path). Use headers to indicate this page is to be downloaded rather than viewed. The user would then open the file in their browser which would let the PDF be viewed (because the webpage is local, from the same IP address). This would work in IE, Opera but not Chrome, FF or Safari.

  4. (What I would do) Make an application (.exe) in say Visual Studio C++. Embed the PDF viewer as activex, using the known url to the PDF (which could be stored in a static char array so your server side script could directly edit the exe to put the PDFs path in it). Then I would use the browser component to embed a browser next to the PDF on the screen - thus showing your online webpage next to the PDF, even if one can't be embedded in the other.

From Dev at http://yumyar.com

这篇关于在HTML页面中嵌入本地PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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