943,909 Members | Top Members by Rank

Ad:
Jun 16th, 2009
0

PDF Preload

Expand Post »
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.
Similar Threads
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007
Jun 16th, 2009
0

Re: PDF Preload

it is possible with JavaScript not possible in HTML, post this in JavaScript forum
Reputation Points: 12
Solved Threads: 34
Posting Whiz
sreein1986 is offline Offline
306 posts
since May 2008
Jun 16th, 2009
0

Re: PDF Preload

Put this in the head tag of your webpage:
HTML and CSS Syntax (Toggle Plain Text)
  1. <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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
silviubogan is offline Offline
9 posts
since Jun 2009
Jun 17th, 2009
0

Re: PDF Preload

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.
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007
Jun 17th, 2009
0

Re: PDF Preload

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
javascript Syntax (Toggle Plain Text)
  1. <script language="javascript" type="text/javascript">
  2. //<![CDATA[
  3. <!--
  4. image1 = new Image();
  5. image1.src = "http://mysite.com/mypdf.pdf";
  6. //-->
  7. //]]>
  8. </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
Last edited by almostbob; Jun 17th, 2009 at 10:46 am.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Jun 17th, 2009
0

Re: PDF Preload

thanks almostbob, i'll try it out...
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007
Jun 18th, 2009
0

Re: PDF Preload

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
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Tabs problem
Next Thread in HTML and CSS Forum Timeline: Dreamweaver Replace





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC