I have a button and use window.print()
to print the page ,
but it is printing only a singe page of what is visible in the viewport. However the page is long enough to fill 5 pages.
How can I get it to print the whole page?
You need to create a separate css file for print whole page.
<link rel="stylesheet" href="css/print.css" type="text/css" media="print"/>
You can define following width in your css file.
body, html, #wrapper {
width: 100%;
}