Scott Ferguson
Scott Ferguson

Reputation: 7830

Printing contents of an iframe caused blank first page

I have a web page that contains 3 images. When I print this page directly from Internet Explorer, it correctly prints 3 pages (1 for each image).

If however I load this exact page as the contents of an iframe and print the contents of that iframe, then internet explorer inserts a blank first page (with IE header's and footers) before printing the 3 actual pages.

Same URL, same browser, but printing the iframe contents produces an extra page, compared to printing from the source page directly.

Any ideas?

Upvotes: 1

Views: 3188

Answers (1)

Yashman Gupta
Yashman Gupta

Reputation: 296

Hope the below might be helpful. May be you can try like this

iFrame Page:, just replace the image. The <p style="page-break-before: always"> code will give the page breaks while printing and noprint class will hide the Print link from the physical printout.

<html>
<head>
    <title>TESTING IFRAME PRINTING</title>
    <style>
    @media print
    { 
        .noprint {display:none;}
    }
    </style>
</head>
<body topmargin="0" marginheight="0">
    <a href="#" onClick="javascript:window.print();"><font face="arial" size="2" class="noprint">Print Now</font></a><br>
    <img src="printer.png">
    <p style="page-break-before: always">
    <img src="printer.png">
    <p style="page-break-before: always">
    <img src="printer.png">
</body>
</html>

Main Page

<html>
<head>
    <title>TESTING IFRAME PRINTING</title>
</head>
<body topmargin="0" marginheight="0">
    <iframe name="iFrameForPrint" id="iFrameForPrint" src="1.html" width="50%" height="400" frameborder="1"></iframe>
</body>
</html>

Upvotes: 1

Related Questions