views:

104

answers:

1

I have an html application running in IE6(yes it has to be 6 for the time being), currently I print a page/report of the application. This report is all html and just uses the browsers built in print functionality. It currently spans more that 1 page i.e. scrolls, and the printing functionality prints the whole page, even what is not visible.

The question I have, is it possible to print only the visible part of the page. So if the user scrolls, I only print what the user is currently seeing, and nothing else?

+1  A: 

Not without a bit of trickery, I think.

You could try the following. I haven't tried it out but it might work:

  • Give the body and the HTML tag 100% height
  • Give the body a "overflow: hidden"
  • Put the contents of your page into a 100% wide, 100% tall DIV with overflow:auto
  • Scroll to the desired position and click "print"

it might give you the visible portion only. No guarantees, though. If you try it, let me know how it works out.

Pekka
I'll give it a try and let you know how it goes.
broschb
Well, it does restrict printing to one page, the problem now is it always shows top of the page. So no matter were the scroll was in the div w/ overflow:auto, it always prints 1 page worth of the content at the top of that div.I'm still playing w/ it, but any more ideas?
broschb
This got me going on the write track, I added some extra print css attributes, and used javascript to change some properties, and it works great.
broschb
Sounds good. Care to share how you did it for future reference?
Pekka