在jsp中查看客户端pdf
如何在 jsp 中显示客户端 pdf(即硬盘上文件的预览)?
我可以嵌入服务器端 pdf:
<embed src="fw4.pdf" name="preview_image" width=400 height=800
border=0 type="application/pdf" PLUGINSPAGE="http://www.adobe.com/downloads/">
我可以预览客户端 img:
<img src="file:\\\\C:\\temp\\IMG_9990_w.jpg" name=preview_image height="600" width="600">
如何预览客户端 pdf?
我尝试过使用 iframe、嵌入标签(路径与上面的 img 标签中的路径类似)等等。有什么建议吗?
How do I show a client-side pdf (i.e. a preview of a file on their hard-drive) in a jsp?
I can embed a server-side pdf:
<embed src="fw4.pdf" name="preview_image" width=400 height=800
border=0 type="application/pdf" PLUGINSPAGE="http://www.adobe.com/downloads/">
I can preview a client-side img:
<img src="file:\\\\C:\\temp\\IMG_9990_w.jpg" name=preview_image height="600" width="600">
How do I preview a client-side pdf?
I have tried using iframes, embed tags (with the path similar to one in the img tag above), etc., etc.. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在embed src
中定义其路径,就像为img src
所做的那样。更新:好的,那没用。不过,你那里的情况也相当罕见。通常,PDF 和所有其他嵌入式内容由网络服务器提供服务,而不是从客户端的本地磁盘文件系统加载。为什么有这个要求?它是否是一个正在访问某些共享网络驱动器的 Intranet Web 应用程序,该驱动器应该在所有客户端计算机上可用?
如果情况确实如此,那么我也会将该网络磁盘附加到网络服务器上,并仅使用 servlet 将未更改的字节从该磁盘流式传输到 HTTP 响应,然后让
嵌入 src
指向该servlet。如果情况并非如此,那么我真的看不出有任何合理的理由来设计这样的网页,或者它一定是为了某些特定的个人目的。
Just define its path inembed src
the same way as you did forimg src
.Update: OK, that didn't work. The case which you have there is also pretty rare though. Normally PDF's and all other embedded stuff is served by the webserver, not loaded from the client's local disk file system. Why this requirement? Is it an intranet webapplication which is accessing some shared network drive which is supposed to be available on all client machines?
If that is indeed the case, then I'd attach that network disk on the webserver as well and just use a servlet to stream the bytes unchanged from that disk to the HTTP response and then let the
embed src
point to that servlet.If that is not the case, then I really don't see any sensible reasons to design your webpage like that, or it must be for some specific personal purposes.