Skip to content

Commit

Permalink
Merge pull request #466 from ozone89/master
Browse files Browse the repository at this point in the history
Implement Code39
  • Loading branch information
DantSu authored Oct 23, 2023
2 parents 25e8923 + 67152ab commit f61030e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f61030e

Please sign in to comment.