[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2003-10-22
7
Medium Priority
?
1,154 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 500 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

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!

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month18 days, 16 hours left to enroll

834 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