File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Java Printing (automated) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Printing (automated)" Watch "Java Printing (automated)" New topic

Java Printing (automated)

David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 212

I have an application written by myself which creates XML documents as the result of specific transactions and as such I have control over their content. I would like to write a separate routine (probably without any GUI) that will constantly monitor the contents of a directory for XML files. Once found a document will be read (parsed) and a report generated. I would like to embed the name of the print queue in the XML document so that multiple prints can be sent to various printers. In actual fact the report will simply consist of a stream of ASCII codes sent to a barcode printer and as such it would be desirable to either bypass a printer driver or use something like a 'Microsoft Generic Printer' to avoid any additional formating to the data.

So my questions :-

Can you programatically specify the name of a printer without invoking a conventional printer selection dialog box.

Can you make this printer the 'default' as you can in Windows (albeit manually from the printers folder).

I want to send data to a networked printer without a driver messing around with the data. The current VB6 application just prints to a generic text only printer driver - is that still the best approach ? Even a generic text only driver can wrap lines and insert perforation skips if you are not precise when you setup the queue.

Lots questions, sorry about that.

Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
Back in the old days you could just send bytes to LPT1: and that would be it.... no intermediary. But I'm sure your code isn't going to have an imbedded print driver, is it? So I conclude that you WILL need to use a printer driver.

I would be asking if there was a way to drop a file onto a printer (on a Windows platform, I presume). Then your program could read the file, pulling out the destination printer, create a file for printing, and then the magical step of dropping the file on the printer would happen. But you'd need to use some native code to do that. Someone else might have done it for you. Let us know what you find.
I agree. Here's the link:
subject: Java Printing (automated)
It's not a secret anymore!