Reputation: 404
I have tried using the https://github.com/gilf/ngPrint directive for print. I can able to print the page but the page design is completely collapsed while printing. Is there any possible way to print the page as it is? Note: Am using Angular Material for the pages
Upvotes: 4
Views: 3319
Reputation: 406
You can try the below piece of code:
function printPage() {
var contentToPrint = document.getElementById('#myDiv').innerHTML;
var windowPopup = window.open('', '_blank', 'width=500,height=500');
windowPopup.document.open();
windowPopup.document.write('<html><head><link rel="stylesheet" type="text/css" href="" /></head><body onload="window.print()">' + contentToPrint + '</body></html>');
windowPopup.document.close();
}
Upvotes: 4