Solved

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

Posted on 2003-10-22
7
1,142 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now