Hello everyone,
I need some direction as to where to go next on this issue.
I am trying to take text data that contains commands with data and ascii control codes for a Citizen Barcode printer and allow my client (a web browser) the ability to print this data to its local printer and generate labels (not the raw data)
I have been able to code a servlet that can prints my barcodes to the local printers on my PC, but I cannot access a client's collection of printers from the web server.
It seems I need to render the data and do a window.print() in Javascript: Here is my servlet code that works when the printer is local to the web server.
try {
PrintService psCitizen = null;
String sPrinterName = null;
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
for (int i = 0; i < services.length; i++) {
sPrinterName = services.getName().toUpperCase();
log(Trace.DIAGNOSTIC, "Printer " + i + ":" + sPrinterName);
if (sPrinterName.toUpperCase().indexOf("CITIZEN") >= 0) {
psCitizen = services[i];
break;
}
}
if (psCitizen == null) {
log(Trace.DIAGNOSTIC, "Citizen printer is not found. Ps Count = " + services.length);
return;
}
DocPrintJob job = job = psCitizen.createPrintJob();
//String STX = "^B";
//String CR = "^M";
String STX = "\002";
String CR = "\015";
//String STX = (char)2 + "";
//String CR = (char)13 + "";
String s = "";
s += STX + "RN" + CR;
s += STX + "e" + CR;
s += STX + "M2982" + CR;
s += STX + "O0100" + CR;
s += STX + "f170" + CR;
s += STX + "qC" + CR;
s += STX + "L" + CR;
s += "H16" + CR;
s += "D11" + CR;
s += "PH" + CR;
s += "SC" + CR;
s += "W" + CR;
s += "Q0001" + CR;
s += "264400005930182DFW" + CR;
s += "232200005840339ORD" + CR;
s += "2e4411005360035BORD4721215005800001" + CR;
s += "241100003160222TEST" + CR;
s += "232100003160243Consignee:" + CR;
s += "241100003160268TEST INTERNATIONAL, PHILA" + CR;
s += "232100003160288Shipper:" + CR;
s += "232100003160314Deliver By:" + CR;
s += "232100002190192 5" + CR;
s += "23210000142031409/23/06" + CR;
s += "26210000310033412150058" + CR;
s += "232100001590192Pieces" + CR;
s += "241100002500192OF" + CR;
s += "231100003760015ORD4721215005800001" + CR;
s += "231100005840162Comment:" + CR;
s += "232100003160192 1" + CR;
s += "E" + CR;
s += "";
byte[] by = s.getBytes();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(by, flavor, null);
job.print(doc, null);
} catch (PrintException e) {
}
How can I using a servlet, JSP or Javascript get the user to print the label data from the client browser and have the thermal printer interpret the browser data as commands to print. I don't mind the browser user having to select the printer.
Thanks!