Solved

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

Posted on 2003-10-22
7
1,143 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
API Soap Calls 4 86
logo disappears on cell phones 5 55
increase words that display in widget 6 56
Retrieve response header - authorization bearer token 34 87
Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

930 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

11 Experts available now in Live!

Get 1:1 Help Now