Solved

Controlling Browser Orientation Setting from HTML

Posted on 2003-10-31
7
1,126 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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

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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
email validation 9 62
Add a little space on either side of a table. 12 32
How do I update select listbox after search 2 49
Need advice on an App idea......but who do I ask? 2 69
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

737 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