【发布时间】:2016-09-17 10:25:27
【问题描述】:
我尝试使用https://github.com/gilf/ngPrint 指令进行打印。我可以打印页面,但打印时页面设计完全折叠。有没有办法按原样打印页面? 注意:我正在为页面使用 Angular Material
【问题讨论】:
标签: javascript angularjs angular-material
我尝试使用https://github.com/gilf/ngPrint 指令进行打印。我可以打印页面,但打印时页面设计完全折叠。有没有办法按原样打印页面? 注意:我正在为页面使用 Angular Material
【问题讨论】:
标签: javascript angularjs angular-material
你可以试试下面的代码:
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();
}
【讨论】:
<head><link rel="stylesheet" type="text/css" href="styles/main.css" type=\"text/css\" media=\"print\" /></head>