diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java b/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java index c210400..445a399 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java @@ -68,6 +68,7 @@ public class EscPosPrinterCommands { public static final int BARCODE_TYPE_UPCE = 66; public static final int BARCODE_TYPE_EAN13 = 67; public static final int BARCODE_TYPE_EAN8 = 68; + public static final int BARCODE_TYPE_39 = 69; public static final int BARCODE_TYPE_ITF = 70; public static final int BARCODE_TYPE_128 = 73; diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/barcode/Barcode39.java b/escposprinter/src/main/java/com/dantsu/escposprinter/barcode/Barcode39.java new file mode 100644 index 0000000..628f601 --- /dev/null +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/barcode/Barcode39.java @@ -0,0 +1,21 @@ +package com.dantsu.escposprinter.barcode; + +import com.dantsu.escposprinter.EscPosPrinterSize; +import com.dantsu.escposprinter.EscPosPrinterCommands; +import com.dantsu.escposprinter.exceptions.EscPosBarcodeException; + +public class Barcode39 extends Barcode { + public Barcode39(EscPosPrinterSize printerSize, String code, float widthMM, float heightMM, int textPosition) throws EscPosBarcodeException { + super(printerSize, EscPosPrinterCommands.BARCODE_TYPE_39, code, widthMM, heightMM, textPosition); + } + + @Override + public int getCodeLength() { + return this.code.length(); + } + + @Override + public int getColsCount() { + return (this.getCodeLength() + 4) * 16; + } +} diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParser.java b/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParser.java index 3b7b3ab..0c56113 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParser.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParser.java @@ -27,6 +27,7 @@ public class PrinterTextParser { public static final String ATTR_BARCODE_TYPE_UPCA = "upca"; public static final String ATTR_BARCODE_TYPE_UPCE = "upce"; public static final String ATTR_BARCODE_TYPE_128 = "128"; + public static final String ATTR_BARCODE_TYPE_39 = "39"; public static final String ATTR_BARCODE_TEXT_POSITION = "text"; public static final String ATTR_BARCODE_TEXT_POSITION_NONE = "none"; public static final String ATTR_BARCODE_TEXT_POSITION_ABOVE = "above"; diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserBarcode.java b/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserBarcode.java index 792f456..a6e052f 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserBarcode.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserBarcode.java @@ -6,6 +6,7 @@ import com.dantsu.escposprinter.EscPosPrinterCommands; import com.dantsu.escposprinter.barcode.Barcode; import com.dantsu.escposprinter.barcode.Barcode128; +import com.dantsu.escposprinter.barcode.Barcode39; import com.dantsu.escposprinter.barcode.BarcodeEAN13; import com.dantsu.escposprinter.barcode.BarcodeEAN8; import com.dantsu.escposprinter.barcode.BarcodeUPCA; @@ -114,6 +115,9 @@ public PrinterTextParserBarcode(PrinterTextParserColumn printerTextParserColumn, case PrinterTextParser.ATTR_BARCODE_TYPE_128: this.barcode = new Barcode128(printer, code, width, height, textPosition); break; + case PrinterTextParser.ATTR_BARCODE_TYPE_39: + this.barcode = new Barcode39(printer, code, width, height, textPosition); + break; default: throw new EscPosParserException("Invalid barcode attribute : " + PrinterTextParser.ATTR_BARCODE_TYPE); }