954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to set landscape orientation?

Hi Guys,

I m writing one HTML page where i wanted the page orientation to be set to LANDSCAPE through Javascript or CSS. So when I click on Print button or anyways on the HTML page, the print window will pop-up so now in that orientation property should be set to LANDSCAPE.

So does anyone know how to accomplish this?

Thanks in advance.

vivekgalatage
Newbie Poster
6 posts since Aug 2004
Reputation Points: 12
Solved Threads: 0
 
tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

I'm confused how one can set the page orientation of a website. One can simply stretch a browser window to any shape and size they want and if relative values are used for tables and such, the text will stretch along with the window.

cscgal
The Queen of DaniWeb
Administrator
19,437 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 
I'm confused how one can set the page orientation of a website. One can simply stretch a browser window to any shape and size they want and if relative values are used for tables and such, the text will stretch along with the window.


Dani,

You can apply CSS style rules to create a custom-sized print box. What you cannot do is force the Print Dialog box to default to landscape. CSS and/or JavaScript cannot reach into the system resources.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

Oh I see what you're saying. Use JavaScript to load the print dialog box. Gotcha there ;)

cscgal
The Queen of DaniWeb
Administrator
19,437 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

No, not quite. The CSS specification allows you to set styles that come into play when the user Prints. So the site may display one way, but when you print, certain elements will be excluded, etc.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

The CSS for this is simple (just use class="landscape"):

So there.

scandal_uk
Newbie Poster
1 post since Jan 2005
Reputation Points: 10
Solved Threads: 0
 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

jasbrown
Newbie Poster
1 post since Feb 2005
Reputation Points: 10
Solved Threads: 0
 

I have been attempting the same CSS implementation, but I read in a book today that Opera 6/7 is the only browser which supports the property which sets the orientation. :sad:

greenbirdweb
Newbie Poster
1 post since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

Hi vivekgalatage,
Did you find a way to do this?. thanks....

gangireddy
Newbie Poster
1 post since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

I tried the code mentioned above in the css but it doesnot work. Is there any other way to do this?

aarti_ap
Newbie Poster
1 post since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

There is no way to do this. Print orientation is something the USER specifies, via their print dialog box. You cannot and should not want to control this. The answer is to specify a print style sheet that formats the document in such a way that landscape orientation is not required.

This falls into the same category of developers wanting to "disable" the user's Back button. That's a no-no. That's part of the USER interface. The proper way to handle the situation is to assume they MIGHT press BACK, and write code to handle that eventuality.

You cannot FIX a problem by BREAKING user functionality.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

There is no way to do this. Print orientation is something the USER specifies, via their print dialog box. You cannot and should not want to control this. The answer is to specify a print style sheet that formats the document in such a way that landscape orientation is not required.

This falls into the same category of developers wanting to "disable" the user's Back button. That's a no-no. That's part of the USER interface. The proper way to handle the situation is to assume they MIGHT press BACK, and write code to handle that eventuality.

You cannot FIX a problem by BREAKING user functionality.

I think you are assuming this is for a wrongly designed page. In my case I need landscape printing of a print version of a page. The client requires this.

So I have come to the conclusion that this works in firefox:

@page land {size: landscape;}

While this is suppose to work in IE:

.land{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1)}

HTML:

<BODY class="land">

My problem is IE. It looks great in the preview, but it just doesn't send it to the printer.

Danne
Newbie Poster
2 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

You're posting in a thread that's over a year old... and I don't see a question in your post. Would you mind starting a new thread, and ask your question, if you have one, there?

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

My question is:

What is wrong since it doesn't print, but shows the page the way I want in the browserpreview (IE)?

Danne
Newbie Poster
2 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

hi, my name is Mikalush
i have the same problem,
and i'm looking for a resault for few days
if anyone know what to do, i'll be very happy!

:idea:

rutigold
Newbie Poster
4 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 
mohammad20001
Newbie Poster
1 post since Feb 2007
Reputation Points: 10
Solved Threads: 0
 
Use the css on the http://home.tampabay.rr.com/bmerkey/examples/landscape-test.html :)


thanks a lot!

you are the first to give me answer that it's possible,

i'll try it later..

have a good day:lol:

rutigold
Newbie Poster
4 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

OK I try it and it's really works!!

but - the quality of the print is not very good, the write is not so clear,
and also the table is not printing on all the width of the page.

any help?

:rolleyes:

thanks!!

rutigold
Newbie Poster
4 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

This function belongs to the user, not the webmaster. If the user wants a landscape print, he can open the file menu and select it.

Remember that some users have printers which don't do landscape orientation.

MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You