I am working on a project and I want to print div content.The code which I am using is fulfilling my requirements,but I am getting simple output without Css applied to it an
Pass the div to be printed, as an input to print function,
Then clone the element,
function printDiv(elem)
{
renderMe($('').append($(elem).clone()).html());
}
Pass the cloned element to render, include the stylesheet in it.
function renderMe(data) {
var mywindow = window.open('', 'invoice-box', 'height=1000,width=1000');
mywindow.document.write('invoice-box ');
mywindow.document.write('');
mywindow.document.write('');
mywindow.document.write(data);
mywindow.document.write('');
setTimeout(function () {
mywindow.print();
mywindow.close();
}, 1000)
return true;
}
If innerHTML is passed, it will ignore the styles.