I would like to print a Web page in landscape mode. When I use window.print() function it prints default in Potrait mode.

I need to print the Web page in Landscape mode with out asking the user to change the setting.

The JavaScript window.print() method simply passes a print request to the underlying OS, which will bring up a dialog box. The user will select portrait or landscape from that box. In other words, print orientation is up to the user, as it should be in my opinion.

tgreer is right. I agree with tgreer that the user should always be allowed to have control over the print attributes. However, I do wish there was a way that the web developer could indicate printing defaults for a document that then the user could override if they wanted.

There are ActiveX components to do this. (Probably Java applets as well.) I used an ActiveX component once that worked by allowing you to specific things such as the page header and footer, portrait or landscape, etc. The component then saved the user's settings, temporarily changed them, sent your page to the OS for printing, then restored the user's page settings.

Check out http://www.meadroid.com/scriptx/index.asp. It's the component I used before.

Hi,

I found this code source that can be use to print in landscape mode.

In HEAD tag you must put:

<style type="text/css" media="print">
div.breakbefore
{
page-break-before:always
}

table.page
{
filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=3);
}
</style>


After BODY tag you must use a TABLE tag that contais all content of the page:

<BODY>
<TABLE class="page">
... Your page ...
</TABLE>
</BODY>

This article has been dead for over six months. Start a new discussion instead.