DEV Community

Alexandre Freire
Alexandre Freire

Posted on

Change Window.print() paper orientation

Hello. Today we will see how to change the orientation of the Window.print () paper with js. To do this, you need to inject style into your document.

var css = '@page { size: landscape; }',
    head = document.head || document.getElementsByTagName('head')[0],
    style = document.createElement('style');

style.type = 'text/css'; = 'print';

if (style.styleSheet){
  style.styleSheet.cssText = css;
} else {



//don't forget to find and remove style if you don't want all you documents stay in landscape
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

rubemfsv profile image
Rubem Vasconcelos

Nice solution.