getCodeBarCommand static method

Uint8List? getCodeBarCommand(
  1. String str,
  2. int nType,
  3. int nWidthX,
  4. int nHeight,
  5. int nHriFontType,
  6. int nHriFontPosition,
)

打印一维条码 @param str 打印条码字符 @param nType 条码类型(65~73) @param nWidthX 条码宽度 @param nHeight 条码高度 @param nHriFontType HRI字型 @param nHriFontPosition HRI位置 @return

Implementation

static Uint8List? getCodeBarCommand(
  String str,
  int nType,
  int nWidthX,
  int nHeight,
  int nHriFontType,
  int nHriFontPosition,
) {
  if (nType < 0x41 ||
      nType > 0x49 ||
      nWidthX < 2 ||
      nWidthX > 6 ||
      nHeight < 1 ||
      nHeight > 255 ||
      str.isEmpty) return null;

  final bCodeData = Uint8List.fromList(str.codeUnits);

  final command = Uint8List(bCodeData.length + 16);
  command[0] = 29;
  command[1] = 119;
  command[2] = nWidthX;
  command[3] = 29;
  command[4] = 104;
  command[5] = nHeight;
  command[6] = 29;
  command[7] = 102;
  command[8] = (nHriFontType & 0x01);
  command[9] = 29;
  command[10] = 72;
  command[11] = (nHriFontPosition & 0x03);
  command[12] = 29;
  command[13] = 107;
  command[14] = nType;
  command[15] = bCodeData.length;
  arraycopy(bCodeData, 0, command, 16, bCodeData.length);

  return command;
}