Page 1
Android Label Print SDK Programming Manual Version 1.04...
Page 2
CITIZEN Android Label Print SDK — Programming Manual Revision History Date Version Description Sep 28, 2016 1.00 First issue. - Renamed the namespace to “com.citizen.sdk.labelprint”. - Added an explanation of ParallelErrorOutput to printerCheck method. Mar 15, 2017 - Added the measurementUnit as a parameter of drawTextLocalFont method.
Page 3
Java is a registered trademark of Oracle in the United States and/or other countries. Company names and product names appearing on this document are trademarks and/or registered trademarks of respective companies. CITIZEN is a registered trademark of Citizen Watch Co., Ltd.
CITIZEN Android Label Print SDK — Programming Manual Table of Contents 1. Introduction ..............................6 1.1. Who should read this document ......................... 6 1.2. System summary ............................6 1.3. Adding library to your .net project ......................8 1.4. Program structure ............................ 10 1.5.
1. Introduction This document is a programming manual for the CITIZEN Android Label Print SDK. 1.1. Who should read this document This document is intended for developers who integrate their Android application programs with Citizen label printers. 1.2. System summary This SDK is referred by Android application program to control Citizen Label printers.
Page 7
CITIZEN Android Label Print SDK — Programming Manual CL-E300EX/303EX Wired/Wireless LAN, USB, Bluetooth Direct thermal CL-E321/331 Wired LAN, USB Direct thermal/Thermal tranfer CL-E321EX/331EX Wired/Wireless LAN, USB, Bluetooth Direct thermal/Thermal tranfer Refer to each user’s manual for more details.
CITIZEN Android Label Print SDK — Programming Manual 1.3.Adding library to your .net project Adding Library Place the library file in the “<project>\app\libs” folder as below. Start up the AndroidStudio, Right-click the CSJLabelLib_Android.jar of libs in the folder, please select...
Page 9
CITIZEN Android Label Print SDK — Programming Manual Declaration of Import Add the library file that is provided, if you use this SDK, please import the following three classes. import com.citizen.sdk.labelprint.LabelConst; import com.citizen.sdk.labelprint.LabelPrinter; import com.citizen.sdk.labelprint.LabelDesign;...
CITIZEN Android Label Print SDK — Programming Manual 1.4. Program structure Here is an example program in Java which uses the SDK. // Create an instance( LabelDesign class ) LabelDesign design = new LabelDesign(); // Text design.drawTextPtrFont("Sample Print", LabelConst.CLS_LOCALE_JP, LabelConst.CLS_PRT_FNT_TRIUMVIRATE_B, LabelConst.CLS_RT_NORMAL, 1, 1, LabelConst.CLS_PRT_FNT_SIZE_24, 20,...
CITIZEN Android Label Print SDK — Programming Manual 1.5. Class summary Methods (LabelPrinter class) Method Description LabelPrinter Constructor. setContext Set the context. connect Connects to a printer. disconnect Disconnects with a printer. printerCheck Gets status of a printer. print Prints labels.
Page 13
CITIZEN Android Label Print SDK — Programming Manual Methods (LabelDesign class) Method Description Constructor. LabelDesign Draws text by using a printer device font. drawTextPtrFont Draws text by using a downloaded font. drawTextDLFont Draws text by using a font installed in the terminal.
CITIZEN Android Label Print SDK — Programming Manual 2. API specification 2.1. Return value Return value Description CLS_SUCCESS (0) The operation has been done successfully. CLS_E_CONNECTED (1001) The printer is already connected. CLS_E_DISCONNECT (1002) The printer is not connected. CLS_E_NOTCONNECT (1003) Failed to connect to the printer.
CITIZEN Android Label Print SDK — Programming Manual 2.2. LabelPrinter class 2.2.1 Constructor Syntax LabelPrinter () Parameters none Description Creates an instance of the LabelPrinter class. Return value none Example LabelPrinter printer = new LabelPrinter();...
CITIZEN Android Label Print SDK — Programming Manual 2.2.2 setContext method Syntax int setContext( Context context ) Parameters [IN/OUT] 意味 値 設定可能範囲 context [IN] Context Context : (android.content.Context) Description This method is used to the USB connection and the search printer. Specify the context.
CITIZEN Android Label Print SDK — Programming Manual 2.2.3 connect method Syntax 1) int connect (int connectType, String address) 2) int connect (int connectType, String address, int port) 3) int connect (int connectType, String address, int port, int timeout) 4) int connect (int connectType, UsbDevice device)
Page 18
CITIZEN Android Label Print SDK — Programming Manual Return value Returns CLS_SUCCESS (0) on success, an error code otherwise. See below for the error codes. "2.1 Return value" describes all error codes. Error code Description CLS_E_CONNECTED (1001) The printer is already connected.
CITIZEN Android Label Print SDK — Programming Manual 2.2.4 disconnect method Syntax int disconnect () Parameters none Description Disconnects a printer. This must be called when a connection is no longer needed or when an error occurs. Return value Returns CLS_SUCCESS(0) on success, an error code otherwise. See "2.1 Return...
CITIZEN Android Label Print SDK — Programming Manual 2.2.5 printerCheck method Syntax int printerCheck () Parameters none Description Gets the status of the printer and stores information into the properties, CommandInterpreterInAction, PaperError, RibbonEnd, BatchProcessing, Printing, Pause and WaitingForPeeling. When this method returns an error, a communication failure or a device error might occur. The...
CITIZEN Android Label Print SDK — Programming Manual 2.2.6 print method Syntax int print (LabelDesign design, int quantity) Parameters Parameter [IN/OUT] Description Setting range design [IN] Instance of LabelDesignclass quantity [IN] Number of labels to print 1 - 9999 Description Prints labels by sending a label design created in the LabelDesign class, followed by printer configuration commands if any of properties are set.
CITIZEN Android Label Print SDK — Programming Manual 2.2.7 storeNVBitmap method Syntax int storeNVBitmap (String filePath, String name, int rotation, int width, int height) Parameters Parameter [IN/OUT] Description Setting range filePath [IN] Path to a bitmap file to store name...
CITIZEN Android Label Print SDK — Programming Manual 2.2.8 clearOutPut method Syntax int clearOutput () Parameters none Description Clears data in the print buffer. This triggers the initialization process which is equivalent to the boot sequence. Return value Returns CLS_SUCCESS (0) on success. See "2.1 Return...
CITIZEN Android Label Print SDK — Programming Manual 2.2.9 sendData method Syntax int sendData (byte[] data) Parameters Parameter [IN/OUT] Description Setting range data [IN] Send data Description Sends binary data to a printer. This can be used only when sending raw printer commands to the printer.
(2) The time out value is out of range. CLS_E_NO_LIST (1106) No printer found. Description Searches available Citizen printers and obtains a list of printer information. The connection type and time out value must be specified. setContext() must be called prior to searchCitizenPrinter(). This method doesn't work on the simulator.
Page 27
CITIZEN Android Label Print SDK — Programming Manual bdAddress Bluetooth device address Example int[] errCode = new int[1]; CitizenPrinterInfo[] list = printer.searchCitizenPrinter( LabelConst.CLS_PORT_WiFi, 3, errCode); for (int i = 0; i < list.length; i++) Log.e("Search", "IP Address: " + list[i].ipAddress);...
(2) The time out value is out of range. CLS_E_NO_LIST (1106) No printer found. Description Searches available Citizen printers and obtains a list of printer addresses. The connection type and time out value must be specified. setContext() must be called prior to searchLabelPrinter(). This method doesn't work on the simulator.
CITIZEN Android Label Print SDK — Programming Manual 2.2.13 HorizontalMagnification property Syntax int HorizontalMagnification Attribute Read/Write Description Horizontal dot size. "1" or "2". Setter method int setHorizontalMagnification (int horizontalMagnification) "1" or "2" must be set as a parameter. Returns CLS_SUCCESS (0) on success. See "2.1 Return...
CITIZEN Android Label Print SDK — Programming Manual 2.2.14 VerticalMagnification property Syntax int VerticalMagnification Attribute Read/Write Description Vertical dot size. "1", "2" or "3". Setter method int setVerticalMagnification (int verticalMagnification) "1", "2" or "3" must be set as a parameter.
CITIZEN Android Label Print SDK — Programming Manual 2.2.15 FormatAttribute property Syntax int FormatAttribute Attribute Read/Write Description Specifies how to print the area where multiple objects are overlapped. 0: XOR mode. Overlapped area will not be printed. 1: OR mode. Overlapped area will be printed.
CITIZEN Android Label Print SDK — Programming Manual 2.2.17 MeasurementUnit property Syntax int MeasurementUnit Attribute Read/Write Description Sets the measurement unit. Value Description CLS_UNIT_MILLI (0) Metric system CLS_UNIT_INCH (1) Inch system Setter method int setMeasurementUnit (int measurementUnit) The default value in the printer is "1."...
CITIZEN Android Label Print SDK — Programming Manual 2.2.18 PrintSpeed property Syntax int PrintSpeed Attribute Read/Write Description Sets the print speed. "3.3.Predefined Constants", No.21 for available value. *Initial and maximum value vary depending on the printer model. Setter method int setPrintSpeed (int printSpeed) Returns CLS_SUCCESS (0) on success.
CITIZEN Android Label Print SDK — Programming Manual 2.2.19 FeedSpeed property Syntax int FeedSpeed Attribute Read/Write Description Sets the feed speed. See "3.3.Predefined Constants", No.21 for available value. *Initial and maximum value vary depending on the printer model. Setter method int setFeedSpeed (int feedSpeed) Returns CLS_SUCCESS (0) on success.
CITIZEN Android Label Print SDK — Programming Manual 2.2.20 SlewSpeed property Syntax int SlewSpeed Attribute Read/Write Description Sets the slew speed. See "3.3.Predefined Constants", No.21 for available value. *Initial and maximum value vary depending on the printer model. Setter method int setSlewSpeed (int slewSpeed) Returns CLS_SUCCESS (0) on success.
CITIZEN Android Label Print SDK — Programming Manual 2.2.24 VerticalOffset property Syntax int VerticalOffset Attribute Read/Write Description Sets the vertical offset to adjust the vertical printing position on the paper. Inch system 0000 – 9999 (0.00 inch - 99.99 inches) Metric system 0000 –...
CITIZEN Android Label Print SDK — Programming Manual 2.2.25 HorizontalOffset property Syntax int HorizontalOffset Attribute Read/Write Description Sets the horizontal offset to adjust the horizontal printing position on the paper. Inch system 0000 – 9999 (0.00 inch - 99.99 inches) Metric system 0000 –...
CITIZEN Android Label Print SDK — Programming Manual 2.2.26 MediaHandling property Syntax int MediaHandling Attribute Read/Write Description Sets the way how to handle media after printing. Value Description CLS_MEDIAHANDLING_NONE (0) To print without any special actions. CLS_MEDIAHANDLING_TEAROFF (1) To feed labels to the tear bar.
CITIZEN Android Label Print SDK — Programming Manual 2.2.27 StartOffset property Syntax int StartOffset Attribute Read/Write Description Specifies the distance between paper sensor and print head to change the print starting position. Inch system Metric system Initial Minimum Initial Minimum...
CITIZEN Android Label Print SDK — Programming Manual 2.2.28 StopOffset property Syntax int StopOffset Attribute Read/Write Description Specifies the distance between paper sensor and cutter or peeler to change the print stop position. Note that the initial values are calculated to stop paper at an appropriate position. An insufficient value truncates the printed label, an exceeded value truncates the next label.
CITIZEN Android Label Print SDK — Programming Manual 2.2.29 LabelSensor property Syntax int LabelSensor Attribute Read/Write Description Sets the label sensor type. Value Description CLS_SELSENSOR_NONE (0) None. This assumes that a continuous paper roll is used. Therefore a valid length must be set in the...
CITIZEN Android Label Print SDK — Programming Manual 2.2.30 PrintMethod property Syntax int PrintMethod Attribute Read/Write Description Sets the print method to either thermal transfer or direct thermal. Value Description CLS_PRTMETHOD_TT (0) Thermal transfer CLS_PRTMETHOD_DT (1) Direct thermal Setter method int setPrintMethod (int printMethod) Returns CLS_SUCCESS (0) on success.
CITIZEN Android Label Print SDK — Programming Manual 2.2.31 SensorLocation property Syntax int SensorLocation Attribute Read/Write Description Selects the sensor to use for the models which have multiple paper sensors, front and rear. The choice will be stored in the non-volatile flash memory and will be kept until overwritten.
CITIZEN Android Label Print SDK — Programming Manual 2.2.32 CommandInterpreterInAction property Syntax int CommandInterpreterInAction Attribute Read Description Shows the printer status if the interpreter is processing commands. Note that the status properties won't be updated automatically. printerCheck method checks the status and updates the value, must be called before referring to this property.
CITIZEN Android Label Print SDK — Programming Manual 2.2.33 PaperError property Syntax int PaperError Attribute Read Description Shows the printer status if there is a paper error. Note that the status properties won't be updated automatically. printerCheck method checks the status and updates the value, must be called before referring to this property.
CITIZEN Android Label Print SDK — Programming Manual 2.2.34 RibbonEnd property Syntax int RibbonEnd Attribute Read Description Shows the printer status if there is a ribbon end error. Note that the status properties won't be updated automatically. printerCheck method checks the status and updates the value, must be called before referring to this property.
CITIZEN Android Label Print SDK — Programming Manual 2.2.35 BatchProcessing property Syntax int BatchProcessing Attribute Read Description Shows the status if the printer is processing batch print jobs. Note that the status properties won't be updated automatically. printerCheck method checks the status and updates the value, must be called before referring to this property.
CITIZEN Android Label Print SDK — Programming Manual 2.2.36 Printing property Syntax int Printing Attribute Read Description Shows the status if the printer is currently printing. Note that the status properties won't be updated automatically. printerCheck method checks the status and updates the value, must be called before referring to this property.
CITIZEN Android Label Print SDK — Programming Manual 2.2.37 Pause property Syntax int Pause Attribute Read Description Shows the status if the printer is in the pause mode. Note that the status properties won't be updated automatically. printerCheck method checks the status and updates the value, must be called before referring to this property.
CITIZEN Android Label Print SDK — Programming Manual 2.2.38 WaitingForPeeling property Syntax int WaitingForPeeling Attribute Read Description Shows the status if the printer is in the wait for peeling status. Note that the status properties won't be updated automatically. printerCheck method checks the status and updates the value, must be called before referring to this property.
CITIZEN Android Label Print SDK — Programming Manual 2.3. LabelDesign class 2.3.1 Constructor Syntax LabelDesign () Parameters none Description Creates an instance of the LabelDesign class. Return value none Example LabelDesign design = new LabelDesign();...
CITIZEN Android Label Print SDK — Programming Manual 2.3.2 drawTextPtrFont method Syntax int drawTextPtrFont (String data, int locale, int font, int rotation, int hexp, int vexp, int size, int x, int y) Parameters Parameter [IN/OUT] Description Setting range data [IN]...
Page 58
CITIZEN Android Label Print SDK — Programming Manual Description Draws characters by using a printer device font with specifying options such as rotation, magnification, size and coordinates. Available font sizes depend on typeface. Kanji: 16, 24, 32, 48 *dots Smooth font: 4, 5, 6, 8, 10, 12, 14, 18, 24, 30, 36, 48 Other: Fixed sizes depend on typeface.
CITIZEN Android Label Print SDK — Programming Manual 2.3.3 drawTextDLFont method Syntax int drawTextDLFont (String data, int encoding, String fontID, int rotation, int hexp, int vexp, int point, int x, int y) Parameters Parameter [IN/OUT] Description Setting range data [IN]...
Page 60
CITIZEN Android Label Print SDK — Programming Manual Return value Returns CLS_SUCCESS(0) on success, an error code otherwise. See "2.1 Return value" for the error codes. Example // TrueType font design.drawTextDLFont("TrueType", LabelConst.CLS_ENC_CDPG_IBM850, "S50", LabelConst.CLS_RT_NORMAL, 1, 1, 12, 100, 100); // Bitmap font design.drawTextDLFont("Bitmap",...
CITIZEN Android Label Print SDK — Programming Manual 2.3.4 drawTextLocalFont method Syntax 1) int drawTextLocalFont (String data, Typeface fontType, int rotation, int hRatio, int vRatio, int point, int style, int x, int y) 2) int drawTextLocalFont (String data, Typeface fontType, int rotation, int hRatio, int vRatio,...
CITIZEN Android Label Print SDK — Programming Manual 2.3.5 drawNVBitmap method Syntax int drawNVBitmap (String name, int hexp, int vexp, int x, int y) Parameters Parameter [IN/OUT] Description Setting range name [IN] Graphic file name ASCII characters except below: -Underscore cannot be the first character.
CITIZEN Android Label Print SDK — Programming Manual 2.3.6 drawBitmap method Syntax 1) int drawBitmap (String filePath, int rotation, int width, int height, int x, int y) 2) int drawBitmap (String filePath, int rotation, int width, int height, int x, int y,...
CITIZEN Android Label Print SDK — Programming Manual 2.3.7 drawBarCode method Syntax int drawBarCode (String data, int symbology, int rotation, int thick, int narrow, int height, int x, int y,int showText) Parameters Parameter [IN/OUT] Description Setting range data [IN] String data ASCII code character string.
Page 67
CITIZEN Android Label Print SDK — Programming Manual Description Draws a 1D (one-dimensional) barcode with specifying options such as barcode type, rotation, thick/narrow bar width, coordinates and human readable text. * Supported thick/narrow bar ratio or data type depends on symbology. Refer to the command reference for details.
CITIZEN Android Label Print SDK — Programming Manual 2.3.8 drawMaxiCode method Syntax int drawMaxiCode (String[] data, int rotation, int x, int y) Parameters Parameter [IN/OUT] Description Setting range data [IN] String data ASCII code character string array rotation [IN] Direction of rotation...
CITIZEN Android Label Print SDK — Programming Manual 2.3.9 drawPDF417 method Syntax int drawPDF417 (String data, int encoding, int rotation, int exp, int ECLevel, int x, int y) Parameters Parameter [IN/OUT] Description Setting range data [IN] String data * The characters available with the specified encoding.
CITIZEN Android Label Print SDK — Programming Manual 2.3.10 drawDataMatrix method Syntax int drawDataMatrix (String data, int encoding, int rotation, int exp, int ECLevel, int x, int y) Parameters Parameter [IN/OUT] Description Setting range data [IN] String data -Numeric: Up to 3,116 characters...
CITIZEN Android Label Print SDK — Programming Manual 2.3.11 drawQRCode method Syntax int drawQRCode (String data, int encoding, int rotation, int exp, int ECLevel, int x, int y) int drawQRCode (byte[] bytes, int rotation, int exp, int ECLevel, int x, int y)
CITIZEN Android Label Print SDK — Programming Manual 2.3.12 drawAztec method Syntax int drawAztec (String data, int encoding, int rotation, int exp, int ECLevel, int x, int y) Parameters Parameter [IN/OUT] Description Setting range data [IN] String data * The characters available with the specified encoding.
CITIZEN Android Label Print SDK — Programming Manual 2.3.13 drawGS1DataBar method Syntax int drawGS1DataBar (String[] data, int type, int rotation, int exp, int x, int y) Parameters Parameter [IN/OUT] Description Setting range data [IN] String data ASCII code character string.
CITIZEN Android Label Print SDK — Programming Manual 2.3.14 drawLine method Syntax int drawLine (int x1, int y1, int x2, int y2, int thickness) Parameters Parameter [IN/OUT] Description Setting range [IN] Start position 0000-9999 ( X-coordinate ) * The origin is at bottom-left.(0, 0)
CITIZEN Android Label Print SDK — Programming Manual 2.3.15 drawRect method Syntax int drawRect (int x, int y, int width, int height, int thickness) Parameters Parameter [IN/OUT] Description Setting range [IN] Start position 0000 - 9999 ( X-coordinate) * The origin is at bottom-left.(0, 0)
CITIZEN Android Label Print SDK — Programming Manual 2.3.16 fillRect method Syntax int fillRect (int x, int y, int width, int height, int pattern) Parameters Parameter [IN/OUT] Description Setting range [IN] Start position 0000 - 9999 ( X-coordinate) * The origin is at bottom-left.(0, 0)
CITIZEN Android Label Print SDK — Programming Manual 2.3.17 drawCircle method Syntax int drawCircle (int x, int y, int radius) Parameters Parameter [IN/OUT] Description Setting range [IN] Start position 0000 - 9999 ( X-coordinate, center ) * The origin is at bottom-left.(0, 0)
CITIZEN Android Label Print SDK — Programming Manual 2.3.18 fillCircle method Syntax int fillCircle (int x, int y, int radius, int pattern) Parameters Parameter [IN/OUT] Description Setting range [IN] Start position 0000 - 9999 ( X-coordinate, center ) * The origin is at bottom-left.(0, 0)
CITIZEN Android Label Print SDK — Programming Manual 2.3.19 drawPolygon method Syntax int drawPolygon (int[] x, int[] y) Parameters Parameter [IN/OUT] Description Setting range [IN] X points 0000 - 9999 * The origin is at bottom-left.(0, 0) [IN] Y points Description Draws a closed polygon defined by arrays of x and y coordinates.
CITIZEN Android Label Print SDK — Programming Manual 2.3.20 fillPolygon method Syntax int fillPolygon (int[] x, int[] y, int pattern) Parameters Parameter [IN/OUT] Description Setting range [IN] X points 0000 - 9999 * The origin is at bottom-left.(0, 0) [IN]...
CITIZEN Android Label Print SDK — Programming Manual 2.3.21 embedRawDesignCommand method Syntax int embedRawDesignCommand (byte[] data) Parameters Parameter [IN/OUT] Description Setting range data [IN] Design command Data of binary. Description Embeds raw printer commands to the label design. This allows adding raw label format commands individually.
CITIZEN Android Label Print SDK — Programming Manual 3. Appendix 3.1. Specifying object position The coordinate origin of the label design is at bottom-left. The measurement unit, either inches or millimeters, is set in the printer. The MeasurementUnit property in the LabelPrinter class allows setting the measurement unit.
1: Access log 2: Error log - LogPath Specifies a folder to store the log files. "/temp/citizen" of SD card by default. - LogMaxSize Specifies maximum size to log file in MB. "0" sets the size to "unlimited." Log file name Log files will be stored with a file name "CSJLabelLib_"...
Page 88
CITIZEN Android Label Print SDK — Programming Manual --- Example, get from a property --- 2016/03/10 17:14:25.474 001 PROPERTY set printDarkness <- 10 : Success(0) * The logging function could be a "bottleneck" of processing since it tries to keep the information of every single execution of a method or access to a property.
CITIZEN Android Label Print SDK — Programming Manual 3.3. Predefined Constants Data Type Name Value Description Type Result/Error CLS_SUCCESS 0 Successfully completed CLS_E_CONNECTED 1001 Already connected CLS_E_DISCONNECT 1002 Not connected CLS_E_NOTCONNECT 1003 Failed to connect CLS_E_CONNECT_NOTFOUND 1004 Non supported model...
Page 90
CITIZEN Android Label Print SDK — Programming Manual CLS_PRT_FNT_6 6 System font:6 7 System font:7 CLS_PRT_FNT_7 CLS_PRT_FNT_8 8 System font:8 CLS_PRT_FNT_TRIUMVIRATE 9 Smooth font (Triumvirate) CLS_PRT_FNT_TRIUMVIRATE_B 10 Smooth font (Triumvirate Bold) CLS_PRT_FNT_KANJI 11 Kanji (Writing from left to right) CLS_PRT_FNT_KANJIT...
Need help?
Do you have a question about the CL-S700 and is the answer not in the manual?
Questions and answers