2013-06-26 50 views
0

我已經完成了使用Extjs 4.1的應用程序,通過在新窗口中創建XTemplte打開來實現了打印功能。打印工作非常好。一旦我點擊打印,它將在縱向模式下默認打開,而不是這一個默認情況下如何在橫向模式下打開打印?非常感謝。謝謝。如何使用JavaScript/Extjs進行默認的橫向打印?

這裏是我的代碼:

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)); 
    } 

回答

0

您可以指定在呼叫窗口的高度和寬度window.open像這樣:

var win = window.open('', name, "height=500,width=1000");