我已经使用 Extjs 4.1 完成了应用程序,通过在新窗口中创建 XTemplte 打开实现了打印功能。打印工作非常好。一旦我点击打印,它将默认以纵向模式打开,而不是这个默认如何以横向模式打开打印?非常感谢。谢谢你。
这是我的代码:
if (Ext.isChrome) {
newWin= window.open();
newWin.document.write('<p style="color: #003366;font-weight:bold;font-size:30px; text-align: center">'+titleName+'</p>'+'<p style="color: #003366;font-weight:bold;font-size:10px; text-align: left">'+filterlblInfo+'</p>'+this.generateHTML(GridViewId));
newWin.document.close();
newWin.focus();
newWin.print();
newWin.close();
newWin='';
}
else{
var win = window.open('', name);
win.document.write('<p style="color: #003366;font-weight:bold;font-size:30px; text-align: center">'+titleName+'Currency Type:'+currencyType+'</p>'+'<p style="color: #003366;font-weight:bold;font-size:10px; text-align: left">'+filterlblInfo+'</p>'+this.generateHTML(GridViewId));
setTimeout(function() {
win.document.close();
win.print();
win.close();
}, 1000);
}
generateHTML: function(component) {
return new Ext.XTemplate(
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'<html>',
'<head>',
'<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />',
'<meta http-equiv="X-UA-Compatible" content="IE=9">',
'<style type="text/css" media="print">',
'@page { size: landscape; }',
'</style>',
'<link href="resources/css/default/printer.css" rel="stylesheet" type="text/css" media="screen,print" />',
'</head>',
'<body>',
this.generateBody(component),
'</body>',
'</html>'
).apply(this.prepareData(component));
}