Results 1 to 1 of 1
- 03-06-2008, 03:21 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 1
- Rep Power
- 0
Specifying a Network Printer in Printer Servlet
Hi All,
I would be very grateful if anyone could help with a little issue I am having regarding sending a file to a specific network printer.
Here is a sample of the code I'm using....
FileInputStream fis = new FileInputStream(file);
if (fis == null) {
System.out.print("No File");
return;
}
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
aset.add(new PrinterName("ipp:\\witnw21va\ipp\ITDepartment-HP4050", null));
//PrintServiceAttributeSet aset = HashPrintAttributeSet();
PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);
if (service != null){
System.out.println("Default Printer: " + service.getName());
// Creating DocPrintJob
DocPrintJob job = service.createPrintJob();
try{
Doc doc = new SimpleDoc(fis,flavor,null);
PrintJobWatcher pjDone = new PrintJobWatcher(job);
job.print(doc,aset);
// Wait for the print job to be done
pjDone.waitForDone();
fis.close();
}
Many thanks.
Similar Threads
-
Help with dox matrix printer
By Albert in forum Advanced JavaReplies: 7Last Post: 09-06-2011, 08:50 AM -
Need help with POS printer
By bkirt in forum Java 2DReplies: 13Last Post: 08-29-2010, 11:11 PM -
Sending text to printer
By Java Tip in forum Java TipReplies: 1Last Post: 05-25-2009, 06:14 AM -
please help on java program for printer : this printer is connected to system which
By for453 in forum Java 2DReplies: 0Last Post: 08-09-2007, 06:30 AM -
ElegantJ Printer Bean 1.1
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-06-2007, 03:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks