Is there a way to print a large table of data with 200 or 300 rows all on one page, similar to the Online MS Excel print option 'Fit Sheet on One Page'?
I attempted the code below:
var tble = document.createElement("table");
tble.id = "tble";
document.body.appendChild(tble);
var trtd = "<tr><td>123</td></tr>"
for (var i = 0; i < 300; i++) {
$("#tble").append(trtd);
}
var divs = "<div id='printing'></div>";
$("#printing").append($("#tble"));
$("#printData").click(function() {
var printToDiv = $("#printing");
var newWin = window.open("", "print-window");
newWin.document.open();
newWin.document.write('<html><body onload="window.print()">' + printToDiv.innerHTML + '</body></html>');
newWin.document.close();
setTimeout(function() {
newWin.close();
}, 10);
})
How can I ensure that the printed content fits neatly onto a single page?