Printing Pages with iframes

  • megsuma
  • Born
  • Born
  • User avatar
  • Posts: 3
  • Loc: USA

Post 3+ Months Ago

Hi all, lurked here for a little, first-time poster. I'm faced with a peculiar situation - I've found many resources about printing the content of an iframe, but what about printing a page containing an iframe? The idea here is that we have a banner above the iframe we want to print along with it, but only the first page worth of iframe prints (despite that it's height is set so that the iframe doesn't scroll). On top of that, we actually get the banner first and blank space beneath it for page 1, page 2 is the first page-worth of the frame, and page 3 is blank.

Any ideas/suggestions? I'm at a loss at the moment.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Welcome to ozzu. Hopefully I am understanding your problem correctly. If I am, I think you can achieve this using Javascript. You would link your print button to execute the following javascript inside the iframe which would make so it prints the parent and everything within the parent.

JAVASCRIPT Code: [ Select ]
<script type="text/javascript">
function PrintPage ()
{
   top.window.focus();
   top.window.print();
}
</script>
 
  1. <script type="text/javascript">
  2. function PrintPage ()
  3. {
  4.    top.window.focus();
  5.    top.window.print();
  6. }
  7. </script>
  8.  


Then I made a button to execute that Javascript within the frame:

HTML Code: [ Select ]
<input type="button" value="Print Now!" onClick="PrintPage(); return true;">


You can see an example here:

examples/print-parent-from-iframe/

Hope that helps!
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

After re-reading your problem I think I am understanding more clearly what you mean. You are saying that the iframe actually contains much more content than is displaying on the page, but you want it to print all of the content, not just what is seen. Is that correct? If not, can you clarify more?
  • megsuma
  • Born
  • Born
  • User avatar
  • Posts: 3
  • Loc: USA

Post 3+ Months Ago

Not quite, sorry if I wasn't too clear before. The issue at hand is that the iframe displays the entire page fine, as in there are no scrollbars in the iframe. When printing from the parent page (we have a print dialog appear as the page opens), only one page worth of content from the iframe is printed, regardless of the fact that the frame, as a whole on the page, displays all of the desired content.

Like I said too, print preview shows our header on page one, the first page of iframe content on page 2, and a blank page 3. I'm almost willing to bet this is somehow more an issue in the browser, but any kind of potential workaround would be excellent.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Is it doing this in different browsers too? Have you checked that? I am curious if it might just be a bug with your browser you are using.
  • megsuma
  • Born
  • Born
  • User avatar
  • Posts: 3
  • Loc: USA

Post 3+ Months Ago

It is doing it in different browsers, and while the layout may be slightly different the problem is generally the same: only one page of content prints.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Is the link you are referring to the one on your profile? If not can you provide me the link so that I can take a look at this myself and see if I can help you.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 163 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.