如何在PDF文档之前显示加载屏幕 [英] How to show loading screen before PDF document

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

问题描述

在我们的应用程序中,我们有链接到动态生成的PDF文档。链接看起来像这样 host / 22-5 / file_3136.pdf ,所以对于浏览器来说,它看起来像一个静态的pdf文档。点击链接时会打开一个新窗口。该窗口仅接收PDF文档(不含HTML),并带有以下标题:

In our application we have links to dynamically generated PDF documents. The links look something like this host/22-5/file_3136.pdf so to the browser it seems like a static pdf document. When link is clicked it opens a new window. That window receives PDF document only (no HTML) with headers like:

Content-Disposition: inline; filename=file_3136.pdf
Content-Type: application/pdf

我们希望用户如果安装了PDF插件并能够以正确的文件名保存文档,就能在浏览器中看到PDF。

We want users to be able to see the PDF in the browser if PDF plug-in is installed and to be able save the document with correct filename.

现在我们要添加一个加载屏幕,将在生成PDF时显示。什么是最好的方式来做到这一点,同时保留当前的功能。

Now we want to add a loading screen that would be shown while the PDF is being generated. Whats the best way to do that, while retaining the current functionality.

一种选择是显示加载屏幕,然后在生成完成后重定向到PDF。这需要我将PDF保留在服务器上一段时间。目前,只要响应被发送,它们就会被删除。

One option would be to show the loading screen and then to redirect to PDF when generation is complete. This would require me to retain the PDF on the server for some time. Currently they are being deleted as soon as the response is sent.

另一个选项是用< embed> ,< iframe> < object> 指向服务器上的PDF。

Another option is to send some HTML and javascript (to show the loading page) with <embed>, <iframe> or <object> tag that points to the pdf on the server.

什么是最好的方法?什么与大多数浏览器一起工作?

What the best approach? What works with most browsers?

推荐答案

如果您线性化PDf,您还可以快速显示第一页。我写了两篇文章,介绍线性PDF在 http://www.jpedal.org/PDFblog/2010/11/do-i-have-to-download-the-whole-pdf-if- i-view-it-across-the-internet / http://www.jpedal.org/PDFblog/2010/02/linearized-pdf-files/

If you linearize the PDf you can also display the first page very quickly. I wrote 2 articles introducing linearized PDF at http://www.jpedal.org/PDFblog/2010/11/do-i-have-to-download-the-whole-pdf-if-i-view-it-across-the-internet/ and http://www.jpedal.org/PDFblog/2010/02/linearized-pdf-files/

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

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