views:

42

answers:

3

Have done some research into this topic, but found no relevant answers. What I need is to print a number of PDF files on one of three forms, which are loaded into different trays of a particular printer. I need to specify which printer to use and it's not the default printer. Additionally, I need to specify which tray to use based upon an attribute of each PDF file and be able to switch between them at run time. Java PrintService seems to only be interested in the local default printer. I'd appreciate any suggestions on how to accomplish this task. Thanks.

A: 

You could configure a different printer for each tray in your OS, Then print to that printer depending on the properties of your file.

Romain Hippeau
Thanks, but I'm stuck with the one 4 tray Lexmark W840.
Mike GH
@Mike GH - Are you working in Windows ? If so you can go and configure a printer in Windows and in there configure a tray. Repeat for each tray. In your code go to each printer based on the tray you need. If you are working on another OS the same thing is probably possible.
Romain Hippeau
+1  A: 

The Printer API does allow for talking to different printers other than the default. That being said it is limited. What we did in our shop is to write a JNI layer that talks directly to the Print Queue of Windows and we use that. If you want finer control than the PrintService API provides you will need to write a JNI layer and access that from Java.

Romain Hippeau
A: 

Thanks for all the suggestions, but I think I have worked this out now. I'm using LPR for the printing and org.apache.commons.net.ftp.FTPClient for the tray switching commands. The actual tray commands are in text files. My tests (so far) have been successful and I did not have to install the printer on my workstation.

Mike GH