Muhammed Almaz Muhammed Almaz - 1 year ago 75
Javascript Question

Change Window.print() paper orientation

I want to change paper mode (orientation) on the window print. I want to change it programatically but i could not find anything.


But i do not know , how can i do it.

@media print{@page {size: landscape}}

I dont need it.

function printWindow()
some code here?

Answer Source

You need to inject style to 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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download