Results 1 to 1 of 1
Thread: Sending PCL to Citizen Printer
- 04-02-2009, 02:20 PM #1Member
- Join Date
- Apr 2009
- Rep Power
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.
- By lipkerson in forum Advanced JavaReplies: 12Last Post: 03-18-2016, 06:28 PM
- By Abhinav.k in forum Advanced JavaReplies: 4Last Post: 12-09-2009, 08:26 AM
- By Java Tip in forum Java TipReplies: 1Last Post: 05-25-2009, 06:14 AM
- By JAVA_ER in forum Advanced JavaReplies: 2Last Post: 02-20-2009, 08:25 AM
- By for453 in forum Java 2DReplies: 0Last Post: 08-09-2007, 06:30 AM