Print in Landscape format
127,383
you cannot set this in javascript, you have to do this with html/css:
<style type="text/css" media="print">
@page { size: landscape; }
</style>
EDIT: See this Question and the accepted answer for more information on browser support: Is @Page { size:landscape} obsolete?
Author by
RRMN
Updated on July 08, 2022Comments
-
RRMN almost 2 years
Possible Duplicate:
Landscape printing from HTMLI am using below code to show print window on button click:
function print_onclick() { window.print(); return false; }
I want the page to be printed in Landscape format. Is there any property I can add in above code to make it work ?
Additional Info: Since my page width is 1280 px, when I print it on A4 paper with portrait orientation, the font becomes too small. I want to print only 2 lines. If not landscape, is there a way I can fix the font size of those table cell/divs while printing ?
-
RRMN over 11 yearsThis doesnot seem to work for IE7.
-
hereandnow78 over 11 yearsdo you really have to support ie7? if it is not a must, please do not do not care about ie7
-
farid bekran about 11 yearsvery very useful. thanks.
-
Jared about 11 yearsIt's a must for some people hereannow78. I'm on client site and that's their primary browser.
-
Dave Hollingworth over 10 yearsThis doesn't seem to work in Firefox (version 24 at the moment), but it does work in Chrome (version 30). Generating a PDF is an alternative that would work in all browsers (although more work / more processing required on the server etc.)
-
Jeff almost 10 yearsCan second the fact that works for Chrome 36 but not Firefox 31.
-
Remya R about 8 yearsnot working in firefox
-
James Haug over 7 yearsDoes not work in Chrome 54.0.2840.99 m
-
Abeer Sul over 7 yearsIs this supposed to work in IE11?? it didn't work with me. The default print orientation is always portrait, I have to manually change it from settings
-
Ryan Smith over 3 yearsdeveloper.mozilla.org/en-US/docs/Web/CSS/@page/… This still doesn't seem to be widely supported (No Firefox, No IE, No Safari) even in 2021.