How to Print Multiple Pages With Different Data (i.e. Not A DataGridView Data) in C#

Posted by KASANI007 under C# on 3/9/2015 | Points: 10 | Views : 1618 | Status : [Member] | Replies : 1
How to Print Multiple Pages With Different Data (i.e. Not A DataGridView Data) in C#




Responses

Posted by: Suraj.0241 on: 3/10/2015 [Member] Starter | Points: 25

Up
0
Down
var printContents = document.getElementById('IDFORTHEPRINTDIV').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title></title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(printContents);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
document.body.innerHTML = originalContents;
similarly keep on adding the contents to the mainwindow.Write and it will print.
Thanks

KASANI007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response