Solved

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

Posted on 2003-10-22
7
1,146 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
Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

 
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

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

Suggested Solutions

Title # Comments Views Activity
easy to understand video about affiliated marketing for a beginner 3 68
QQ problem 22 89
Exchange OWA website Redirection 7 80
transfer content to new site design 7 49
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. …
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

732 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