Solved

Controlling Browser Orientation Setting from HTML

Posted on 2003-10-31
7
1,123 Views
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!  

Bill







0
Comment
Question by:pbguy
7 Comments
 
LVL 17

Accepted Solution

by:
dorward earned 25 total points
ID: 9658748
0
 
LVL 31

Assisted Solution

by:seanpowell
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:

<html>
<head>
<title>Landscape Printing</title>
<style type="text/css" media="print">
<!--
div.page  {
writing-mode: tb-rl;
height: 80%;
margin: 10% 0%;
}
-->
</style>
</head>
<body>
<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>
</div>
</body>
</html>
0
 
LVL 19

Assisted Solution

by:webwoman
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.
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 15

Assisted Solution

by:VincentPuglia
VincentPuglia earned 75 total points
ID: 9659072
Hi,

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:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/wb_print.asp

Vinny
0
 
LVL 3

Author Comment

by:pbguy
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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/wb_print.asp

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...

Bill  





 



0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9661585
The following brings up the printer dialog.

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

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.

Vinny
0
 
LVL 3

Author Comment

by:pbguy
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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/beyondprintpreview.asp

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

Bill  

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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…

773 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