Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer Discovery in Java

Status
Not open for further replies.

sgk17

Technical User
Nov 8, 2002
68
US
I am printing barcodes from my Java application and I am looking for a way to programmatically select a barcode printer and have it default to that printer instead of defaulting to the windows default printer. So basically, I want my application to scan for a printer with a paper size of 3x1 and have it print to that unless specified otherwise. I've been looking at PrintServiceLookup, but I haven't been able to find any clear examples of how to do what I'm trying to do. Any help would be appreciated. Thanks.
 
This will look up the printers available to you :

Code:
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;

PrintService[] services = PrintServiceLookup.lookupPrintServices(flava, null);
for (int j = 0; j < services.length; j++) {
 System.out.println(&quot;[PrintPdf] Available Printers : &quot; +services[j]);
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top