Controlling Browser Orientation Setting from HTML

Posted on 2003-10-31
Last Modified: 2010-04-09
Hi all,

Ok, my gut says this is ridiculous, but the pointy-haired managers who said "ok" to the clients refuse to let it go so I need some help.  I would appreciate your input!

I have a web application that produces reports.  The reports can be output to HTML on the browser.

Some of the reports need to be printed in a "landscape" orientation from the browser so the data doesn't overflow (which would involve the user clicking on the "Landscape" radio button under layout orientation after they clicked "print". )

Apparently, this is too much to ask from our users.  They want the page orientation on the browser to automatically be set to the appropriate setting for the report so they "don't have to think."

So, the question -

Is there any way for an HTML page to tell the browser which setting to default the printer page orientation (portrait or landscape)?

A universal solution would be great, but I'll settle for something that works just on IE.  Feel free to sprinkle in CSS or Javascript if needed.

Thanks in advance for any help you can give me!  


Question by:pbguy
LVL 17

Accepted Solution

dorward earned 25 total points
Comment Utility
LVL 31

Assisted Solution

seanpowell earned 50 total points
Comment Utility
Depepnding on how you're doing this, you may be able to use the "writing mode" IE attribute:

<title>Landscape Printing</title>
<style type="text/css" media="print">
<!--  {
writing-mode: tb-rl;
height: 80%;
margin: 10% 0%;
<div class="page">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed
diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam
erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie
consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto.</p>
LVL 19

Assisted Solution

webwoman earned 50 total points
Comment Utility
If this is a public internet app, you're not going to get everyone to use a plugin. If it's an intranet app where you have total control over what's allowed, it's more likely.

And if you're not willing to pay for the ActiveX control, there isn't any way.
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

LVL 15

Assisted Solution

VincentPuglia earned 75 total points
Comment Utility

the following ActiveXObject was created for IE4 because it didn't have the window.print() method.  You can call up the print dialog with it

var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
     document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(6, 1);//Use a 1 vs. a 6 for a prompting dialog box
     WebBrowser1.outerHTML = "";

info at:


Author Comment

Comment Utility
Hi guys,

Thanks for all the ideas, trying to whittle down the options here.  Please correct me if I get confused.  

Remember, the idea is to find some way to automatically set the page orientation to Landscape.

seanpowell - the writingmode=tb-rl css option seems like it will let me print Landscape if the default setting is Portrait (because it writes down the page instead of across...) which is great, unless the default setting is already landscape.  Then it will print in Portrait.  So the user would have to be in Portrait to print Landscape, and Landscape to print Portrait (basically just reverses functionality of the page orientation.)  This would probably be too confusing - especially to troubleshoot 3 months down the line! (actually, this was one of the programmers first swipes at this - this is the behavior we are trying to correct...)

dorward and webwoman - might get by with an Active-X (it is an Intranet app) but they probably won't flip for a commercial package.  Yeah, I know... try working here...or talking reason to them :)

VincentPaglia -
I think we might be closest with your suggestions.  On the page you provided

under "How can I specify the target printer or set Landscape mode and other print attributes?" I followed the "Printing Workarounds" link (unfortunately unable to create a direct link to this page that works for ya...)  and found something that looks like it does what I want it to.  

Unfortunately, not familiar enough with VBScript/ActiveX and this type of stuff to get it to work for me locally.  Would anyone be able to provide example code based on this stuff that lets me set the portrait/landscape settings?

Thanks again for all the input guys - I think we may be on to something...



LVL 15

Expert Comment

Comment Utility
The following brings up the printer dialog.

    "<object id='printID' width=0 height=0 classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'> </object>");
  printID.ExecWB(6, 1);
  printID.outerHTML = "";

To set the orientation automatically, you are either going to have to use vbscript or c/c++  -- in order to reset the Windows registry, and according to the article, the data provided may no longer be viable.

Your clients lawyers?  make them earn their pay.  a click or two won't kill them.


Author Comment

Comment Utility
Sorry for the delay in responding,

Vinny - I hear ya and agree with ya!  Unfortunately, the pointy-haired bosses and incompetent marketing folks won't admit they're missing the point (or that they mispoke to the client) and I'm in the middle.

Anyway, bottom line is that the only way you can control the printer settings is through an ActiveX object.  Unfortunately, I have not been able to get any of the freebies to work on my pages.  

Side note - the ActiveX object uses "print templates" to control the printing, check out Chuck Ainslie's articles for a start at

Unfortunately didn't get a real good conclusion to this question but all the info is out on the table and I think this stuff may be helpful to folks in the future.

Thanks to all who contributed.  Special thanks to Vinny for going the extra yard, however, since there is no clear-cut answer I will split the points with everyone who posted.  

Dorward - just a suggestion, it may be helpful in the future if you gave a little more explaination that just the URL (avoid the "URL Slap")  - was a really helpful link but it took a good while to read through everything to understand what was going on.  Certainly appreciate your contribution in any case.

Thanks all



Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Make code non clickable 6 30
Dynamically changing javascript code 2 43
Condidional <a href = ....> 1 23
JQuery & CSS Tab Issues 7 26
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now