aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes To enable landscape finish for taking printout  using java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "To enable landscape finish for taking printout  using java script" Watch "To enable landscape finish for taking printout  using java script" New topic
Author

To enable landscape finish for taking printout using java script

Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Hi,

Could you tell me as to how I would enable landscape finish for taking printout using java script?

Thanks in advance.


Padma priya N.G.
Be the change you want to be - Mahatma Gandhi
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
JavaScript has no control over this.

In future versions of CSS you can specify it. I think the only browser that supports it was Opera.

The only real solution is to offer a pdf to print or mkae sure you inform the users to change the setting.

Eric
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Can I try the below piece of code?
var shell;
function SetPrintProperties() {
try {
shell = new ActiveXObject("WScript.Shell");
shell.SendKeys("%fu");
window.setTimeout("javascript:SetPaperSize();", 1200);
window.setTimeout("javascript:setLandScape();", 2000);
} catch (e) {
alert('Please verify that your print settings have a Landscape orientation and minimum margins.');
}
}
function SetPaperSize() {
shell.sendKeys("%a{TAB}.2{TAB}0{TAB}0{TAB}0{ENTER}");
}
function setLandScape() {
shell.sendKeys("%fp");
window.print();
}
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Hi,
For using ActiveXObject in Javascript, what is the pre requisite? I am not able to execute it? Everyt time, the code goes to the catch block in IE6.
Thanks in advance.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Your security settings have to be low enough in order to use it.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To enable landscape finish for taking printout using java script