Solved

How do I set printer mode to landscape using javascript?

Posted on 2003-10-23
5
284 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:ssdanu
5 Comments
 
LVL 3

Accepted Solution

by:
alexgreen earned 500 total points
ID: 9605049
don't think that it's possible sorry! Similar conclusion in
http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/216/qid/640789

this might give you better background knowledge
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnscrpt/html/dhtmlprint.asp

there's a possible workaround here
http://www.xml.com/pub/a/2002/10/09/xslfo.html?page=1

and here your answer may be, if you search through the reams of code
http://oldlook.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20730189.html

More printer friendly html resources
http://oldlook.experts-exchange.com/Web/Web_Languages/HTML/Q_20543061.html

possibly helpful
http://oldlook.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20740024.html

scriptx the de facto printing control for the web, developed to provide absolute control over document printing operations from client and server computers running Internet Explorer. A subset of ScriptX printing and script-enhancement functionality is available at no charge and is freely distributable.  possibly the only actual solution to the question.
http://www.meadroid.com/sx_intro.asp
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9610885
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
0
 
LVL 23

Expert Comment

by:sciwriter
ID: 9638024
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.
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10345861
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now