Reputation: 342
I have developed the SAPUI5 application which is having a print option. When I click on print button, I am writing print area content into document and giving print by using window.print();
var printContents = document.getElementById("printArea").innerHTML;
var win = window.open("", "PrintWindow");
win.document.write("<div class='page'>" + printContents + "</div>");
setTimeout(function() {
win.print();
win.stop();
}, 2000);
But the issue is I am missing SAPUI5 default library CSS in my print. I need SAPUI5 default style sheet in my print,how to fix it?
Upvotes: 1
Views: 2863
Reputation: 60
I also came across same problem. Please add below code between "var win..." and "win.document.write...".
$.each(document.styleSheets, function(index, oStyleSheet) {
if(oStyleSheet.href){
var link = document.createElement("link");
link.type = oStyleSheet.type;
link.rel = "stylesheet";
link.href = oStyleSheet.href;
//win.document.head.appendChild(link); --> this doesn't work in IE
win.document.getElementsByTagName("head")[0].innerHTML = win.document.getElementsByTagName("head")[0].innerHTML + link.outerHTML;
}
});
Upvotes: 1