0

I have a large pdf (>1 MB)that i want to preload on a html page that says "Please wait..." and display that at the middle of the screen.. so that users know that the pdf is loading (i know it says it at the bottom of the screen, but i'm worried they might not see that). How can i preload a pdf in an html page and then have it display?

or how to embed a pdf file using html or any language? thank you for any ideas.

4
Contributors
6
Replies
8
Views
9 Years
Discussion Span
Last Post by almostbob
0

Put this in the head tag of your webpage:

<meta http-equiv="refresh" content="2;url=http://www.yourwebsite.com/pdfdoc.pdf">

Replace "2" with the number of seconds the user will wait until he will be redirected to "pdfdoc.pdf" (replace it with your pdf file's path).

You may also use a hidden iframe with the pdf file which will load while the "Loading..." text will be shown to the user. After it is loaded you can make the iframe visible using javascript.

0

i did a search using iframe..for javascript..but there's a lot complaining that their system were injected by a malicious code because of using such method.. any comments for this?

or is there a way to detect if the file has downloaded completely? thank you.

0

It is possible, preferable?, to actually preload the .pdf file so that the impression of instant loading is given.
in the page prior to the pdf linked page add a preload script

<script language="javascript" type="text/javascript">
//<![CDATA[
<!-- 
image1 = new Image();
image1.src = "http://mysite.com/mypdf.pdf";
//-->
//]]>
</script>

The code above placed between </body> and </html> in the page containing the link to the .pdf file (or html file with the .pdf in it) instructs the browser to download the pdf file to the browser cache, but just leave it there.
(filetype is irelevant image() is convenient, use the same script for any filetype as it is not ever going to be rendered)
the download happens after the page is fully rendered so does not delay the current page.
on clicking the link to the .pdf file (or html page) the browser finds the .pdf in the browser cache and does not download it, but displays from the cache, at apparently blinding download speeds.In browsers with javascript disabled, the function degrades gracefully

0

hope it works for you
I use the script to load large images of the inpage thumbnails so the fullsize image changes instalntly on mouseclick
+ have some instructional .pdfs load so they open onclick

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.