7

im using the css file from this location:

http://peterned.home.xs4all.nl/examples/csslayout1.html

but somehow, when i print my page, the first page is perfect, but it starts to print a second page which is blank.

Ofcourse i only need the first page, but i cannot find why it prints a second blank page. Did someone encounter this before, or know what i should change?

I think somehow the css file has some properties in it, which makes my page maybe just a bit too big.

user2133342
  • 151
  • 1
  • 2
  • 8
  • i just tried it in chrome. it only wants to print one page. – btevfik Mar 30 '13 at 11:30
  • thanks for trying it. i'm using firefox, and it is to print this page which is opened by javascript in a popup: http://pastebin.com/ap2wUC6t . The popup was given a height of 1200px but even changing that is just for the popup window, and does not matter for the content when printing. – user2133342 Mar 30 '13 at 11:37

3 Answers3

8

I had the same problem just now and found user2624602 answer hepful.

In the css just add:

@media print { html, body { height: 99%; } }
Community
  • 1
  • 1
Dennis Bauszus
  • 1,624
  • 2
  • 19
  • 44
  • (Addition) If you say your body and/or html has a height and you than add padding och margin to it, it vill get higher and thereby create and extra blank page. – Andreas Jan 21 '15 at 09:23
1

As far as I know, it very depends on the browser: with firefox it's quite independent from the pc you're using, while with chrome it depends both on your pc and the currenct page-zoom.

For example here I don't see any problem (both ff and chrome).

Anyway, you can try playing with this css2 property: page-break-after:avoid;.

alexcasalboni
  • 1,726
  • 1
  • 16
  • 26
0

In the php code you provided you have an error in the end.

</table>

</body></div>
<div id="footer">
<p><img src="images/voet.png" alt="Kop" class="voet"/></p>

</div>

</div>
</html>

Should probably be something like:

          </table>

        </div>
        <div id="footer">
          <p><img src="images/voet.png" alt="Kop" class="voet"/></p>       
        </div>

      </div>
  </body>
</html>
user1823799
  • 120
  • 7
  • Additionally, you are opening an body tag on line 19, inside the . Between the head and body you have some divs. They should be within the body element. I am not sure wheather this is the problem for printing but try to fix these issues first to see if it helps before trying to fix it with css. – user1823799 Mar 30 '13 at 11:52
  • thanks, i just corrected this. still a blank page. looks like the page-break-after:avoid; is not working? – user2133342 Mar 30 '13 at 11:56
  • The page-break-after: avoid; will not help if you actually do have some white space content that the browser tries to print. It would be helpfull to see the real page or if that is not possible an jsfiddle, or just the html file. – user1823799 Mar 30 '13 at 12:08
  • i dont think it is possible, since the content of that php page comes from mysql. i can make a screenshot how it looks, but i guess that won't help? this is the pastebin of my code now: http://pastebin.com/pAjVPrkz – user2133342 Mar 30 '13 at 12:19
  • I see. Can you take view source in your browser so we just get the html and copy it to pastebin? – user1823799 Mar 30 '13 at 12:30
  • Ok, the td element must be closed with /td. – user1823799 Mar 30 '13 at 12:52
  • which td are you reffering to? – user2133342 Mar 30 '13 at 12:56
  • When indented the code looks like this: http://pastebin.com/mGALjFjm and you can see that there are a lot of open tds in the end. – user1823799 Mar 30 '13 at 13:17
  • ook, i have changed all tages to so they are closed, but it doesn't seem to matter for the print problem. it still prints a second blank page (with only the header and footer, like url, date etc.) – user2133342 Mar 30 '13 at 13:27
  • 1
    The td element can not be self-closed. The correct syntax is `Cell content`. This might not be the source of the problem but without correct html syntax it is useless to try to find the problem in the css since different browser will interpret the incorrect syntax in different ways. – user1823799 Mar 30 '13 at 13:44