Link to home
Start Free TrialLog in
Avatar of pbguy
pbguy

asked on

Controlling Browser Orientation Setting from HTML

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







ASKER CERTIFIED SOLUTION
Avatar of dorward
dorward

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of seanpowell
seanpowell
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pbguy
pbguy

ASKER

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  





 



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
Avatar of pbguy

ASKER

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