Solved

PDF-print: window.print() prints only emtpy pages?

Posted on 2003-10-22
7
1,147 Views
Last Modified: 2008-02-01
How to print PDF from HTML page with frameset and JavaScript?

Hi all,
I recieved the following code for a question I posted here:

<frameset rows="100%" onload="window.print();" >
  <frame src="your.pdf" />
</frameset>

This opens the print dialog, so I thought everything's fine. After a real test it does not work: it prints a page but the paper is emtpy (except for date, name of file etc).
I need to get it run at least in IE5+, if I print the tested PDFs with the normal print-button in the PDF button bar it works fine.

Any ideas?
0
Comment
Question by:Smoerble
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 9598081
I would check the path to your pdf file.  With your example above, the pdf file must be in the same folder as the html page - if it isn't, you'll print a blank page.
0
 

Author Comment

by:Smoerble
ID: 9598130
Sure we use correct pths ;)
The PDF is displayed in the browser so we know the path is correct.
0
 

Author Comment

by:Smoerble
ID: 9598357
Another possible solution is the code below.
If we use it with onLoad it still does not work all the time, with the button it works fine (only has to work in IE5+)
Any more ideas someone?

------
<body onLoad="document.getElementById('PdfPlugin').Print();">
<object type="application/pdf" classid="CLSID:CA8A9780-280D-11CF-A24D-444553540000" id="PdfPlugin" width="500" height="400">
<param name="SRC" value="tenka.pdf">
</object>
<input type="Button" name="command" value="Print" onclick="document.getElementById('PdfPlugin').Print();"/>
------
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:tncbbthositg
ID: 9598724
try this:

<frameset rows="100%" onload="document.frames['printframe'].print();">
  <frame id="printframe" src="your.pdf" />
</frameset>

0
 

Author Comment

by:Smoerble
ID: 9598734
Please check the code in my question, this is exactly the same :(
0
 
LVL 8

Accepted Solution

by:
tncbbthositg earned 250 total points
ID: 9598822
no, it's not!

Code in your Question:
window.print();

Code in my answer:
document.frames['printframe'].print();

take a closer look:
<frameset rows="100%" onload="document.frames['printframe'].print();">
  <frame id="printframe" src="your.pdf" />
</frameset>
0
 
LVL 8

Expert Comment

by:tncbbthositg
ID: 9600250
if you arent using xhtml, I would use:

<frameset rows="100%" onload="document.frames['printframe'].print();">
  <frame name="printframe" id="printframe" src="your.pdf" />
</frameset>

just thought I'd add that
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question