Link to home
Start Free TrialLog in
Avatar of ssdanu
ssdanu

asked on

How do I set printer mode to landscape using javascript?

Hi,

 I want to set the printer mode to landscape while printing my page..
I want to do it throu javascript  How do I do it??
 Can  anybody help me with the code for this...


It is very urgent...


Please help as soon as possible


Thanks  & Best Regards
ssdanu
ASKER CERTIFIED SOLUTION
Avatar of alexgreen
alexgreen

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

Hi,

don't know if this will work, but it's worth a try.  

1) assign the page's content to a variable  
   var contentVar = document.getElementsByTagName('body').innerHTML
(dependent on what you want to print, you may have to use outerHTML or text)

2) which you then send to the following page
     pathfilename?contentVar

3) the init() function will parse the location and fill the div with the passed innerHTML

4) everything in the div will be rotated.

<html>
<script>
function init()
{
  txt = location.search.substr(1)
  document.getElementById('theDiv').innerHTML = txt;
}
</script>
<body onload='init()'>
<div id="theDiv" style="position:absolute; top:0px; left:0px; filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1)">
This is some text along with other stuff;
<br />
<table border="1">
<tr>
<td>
<form>
<input type='text' value='something'>
</form>
</td><td>some  more text</td></tr></table>
</DIV>
</body>
</html>

Vinny
It cannot be done, since JS via web pages has no access to the user's local hard drive, which is where the printer settings are stored.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: alexgreen {http:#9605049}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer