File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Printer tray selection from Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Printer tray selection from Javascript" Watch "Printer tray selection from Javascript" New topic
Author

Printer tray selection from Javascript

ruquia tabassum
Ranch Hand

Joined: Jun 23, 2007
Posts: 292

Hi.. i have a printer with A4 size paper in tray 3 and A5 sized paper in Tray 2.. now i want to select printer tray from javascript while printing so that specific pages are printed in A4 and A5.

Can anybody suggect me how do i do this in javascript. I am using media print in html to print the content of div...

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23635

Shouldn't a person specify this when the print dialog comes up? How does the web page know how all user's printers are configured?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 9982

Jeanne - I think you are understating this. I believe that the browser's sandbox should block any access attempts to any hardware.

Ruquia - this may be frustrating for you, but imagine this from a blackhat perspective. There are websites you can go to know that pop up lots of annoying (to say the least) web pages. Or do pop-under sites. Now imagine how much more frustrating it would be if you were to go to a web page and suddenly find that your company's printer is printing thousands of pages of advertisements. Or that the page had told to your printer to reconfigure itself in some way that the printer did not understand, and your printer is no longer working.

So - no access to the printer from within Javascript.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23635

Andrew Monkhouse wrote:Jeanne - I think you are understating this. I believe that the browser's sandbox should block any access attempts to any hardware.

Yes. I was trying to subtly hint that it wasn't possible with JavaScript. The browser absolutely prevents this.

It might be possible with ActiveX, but that's only in IE and only if the user allows ActiveX to run.

[edited to fix quoting]
ruquia tabassum
Ranch Hand

Joined: Jun 23, 2007
Posts: 292

As said by jeanne that its possible in Active X... can anybody give me an example of ActiveX.. when user clicks print button the page should get printed to a particular tray like Tray2.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
ActiveX ... can you afford to exclude everyone who is not running one particular browser on one particular operating systems AND whose security level is set low enough to allow this? While it may be possible, it won't work for many people.
ruquia tabassum
Ranch Hand

Joined: Jun 23, 2007
Posts: 292

As this is a small application just used in my office alone.. i need to any how show the result to my boss.. can you please suggest me an example of Active X
 
 
subject: Printer tray selection from Javascript
 
Threads others viewed
Print content inside the div tag
PrintService - How to access a media tray?
Problem with window.print() in chrome.
pass href paramter from javascript for media print in html
Printer trays
developer file tools