Print the page as it is in AngularJS

I tried using the https://github.com/gilf/ngPrint directive to print. I can print the page, but the page design completely collapsed while printing. Is there a way to print the page as it is? Note. I use Angular Material for pages

+4
source share
1 answer

You can try the following code snippet:

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();
} 
+2
source

Source: https://habr.com/ru/post/1654902/


All Articles