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
ID: 9658748
LVL 31

Assisted Solution

seanpowell earned 50 total points
ID: 9658815
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
ID: 9658820
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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 15

Assisted Solution

VincentPuglia earned 75 total points
ID: 9659072

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

ID: 9660145
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

ID: 9661585
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

ID: 9783260
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML Anchor Link Problem 3 50
Change how page is organized 3 35
SVG and IE11 2 17
CSS - how to make button/link change to black on hover? 2 13
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

713 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