0

I have done application using Extjs 4.1, have implemented print functionality by creating XTemplte opening in new window. Print is working very nicely. once i click print it will open by default in portrait mode, instead of this one how to open print in landscape mode by default? Great appreciated. Thank you.

Here is my code:

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));
    }
Ramesh Lamani
  • 1,117
  • 3
  • 25
  • 54

1 Answers1

0

You specify the height and width of the window in the call to window.open like so:

var win = window.open('', name, "height=500,width=1000");
Reimius
  • 5,694
  • 5
  • 24
  • 42