Search code examples
javascriptcsshtml

window.print() only prints the "viewable" part of the screen


I've a scrollable screen and I'm having a print button on it and "window.print()" function is called on its onclick event.

My problem is it only prints the "viewable" part of the screen, not the whole screen. If a page is scrollable, the print should extend to 2(or more) pages if contents do not fit in 1 page. But in my case, it always print only 1 page and rest of contents are not printed.


Solution

  • Possible duplicate of: window.print() is not printing the whole page

    You basically have to add the following to your main css file

    @media print {
          body, html, #wrapper {
              height: 100%;
          }
    }