Possible Duplicate:
Landscape printing from HTML
I 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 ?
The document or web page may be configured to prevent an image or table of data from spanning across multiple pages, forcing it to Portrait mode. If it's a document, you can reduce the size of the image or table to fit on a page printed in Landscape mode.
Click or tap in the document. Go to Layout > Orientation, and then select Landscape. Go to File > Print. Under Settings, make sure the orientation box says Landscape Orientation.
Use different orientations in the same document Select the pages or paragraphs whose orientation you want to change. Click PAGE LAYOUT > Page Setup dialog box launcher. In the Page Setup box, under Orientation, click Portrait or Landscape. Click the Apply to box, and click Selected text.
Show activity on this post. From the "Page Layout" ribbon, click on "Page Setup." It will open a dialog box to the "Margins" tab. Next to "Multiple pages," select "2 per page." If your page orientation is set to "portrait," the default option is to make two landscape pages, one on top of the other, on a portrait sheet.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With