Sending PCL to Citizen Printer
I have searched a lot and didn't find any thing useful that explains how to send PCL commands to a printer. I managed to do it and thought to share the code maybe some else will use it.
In My case I needed to send a PCL command to the citizen printer CT-S300 to print a barcode.
In the citizen Manual, it showed the examples in Basic language. Something like this:
//Note &H means Hexadecimal, and CHR$ function returns the charachter
//Following prints the barcode for number "123"
And this is the Java code I used for printing:
//Preparing command String
String barcode = "123";
String printBarCodeCommand = (char) 29 + "k" + (char) 4 + barcode + (char) 0;
//Below code is to send the string to the printer
input = new ByteArrayInputStream(printBarCodeCommand.getBytes( ));
flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
aset = null;
printServices = GetPrintService("Citizen CT"); //I will not include code for this function, you can search for it its easy to look up a PrintService
job = services2.createPrintJob();
doc = new SimpleDoc(input, flavor, null);
This should do the job. Please also note that some commands need to be at the beggining of a line, or they will not be executed.
Hope this helps somebody out there.