将位图打印到ESC / POS打印机

时间:2015-08-22 11:14:50

标签: printing thermal-printer

我正在尝试打印到兼容ESC / POS的打印机,我正在努力让我的头脑GS v 0。我刚从Mac连接,通过CoolTerm发送命令hex

文档说......

  GS v 0 m xL xH yL yH d1....dk
  -----------------------------------------------------
  [Name] Print raster bit image
  [Format] ASCII GS v 0 m xL xH yL yH d1....dk
  Hex 1D 76 30 m xL xH yL yH d1....dk
  Decimal 29 118 48 m xL xH yL yH d1....dk
  [Range] 0≤xL≤48, xH=0; 0≤yL≤255, yH=0; 0≤d≤255
  k=(xL+xH×256)×(yL+yH×256)(k≠0)
  [Description] Selects Raster bit-image mode. The value of m selects the mode, as follows:
+------+------------+----------------------------+---------------------------+
|  m   |    MODE    |      Vertical Dot Density  |  Horizontal Dot density   |
+------+------------+----------------------------+---------------------------+
|0, 48 |   Normal   |          200 DPI           |        200 DPI            |
+------+------------+----------------------------+---------------------------+
|1, 49 |Double-width|          200 DPI           |        100 DPI            |
+------+-------------+---------------------------+---------------------------+
|2, 50 |Double-height|         100 DPI           |        200 DPI            |
+------+-------------+---------------------------+---------------------------+
|3, 51 | Quadruple  |          100 DPI           |        100 DPI            |
+------+-------------+---------------------------+---------------------------+

 • xL, xH, select the number of data bits ( xL+ xH × 256) in the horizontal direction for the bit image.
 • yL, yH, select the number of data bits ( yL+ yH × 256) in the vertical direction for the bit image.
 • This command has no effect in all print modes (character size, emphasized, double-strike, upside-down, underline, white/black reverse printing, etc.) for raster bit image.
 • The part of bit image that exceeds the printable area will not be printed.
 • d indicates the bit-image data. Set time a bit to 1 prints a dot and setting it to 0 does not print a dot.

因此,我推断我需要在HEX

中发送以下内容
 1D 76 30 30 20 00 00 01

现在图像数据是否遵循这一点,我是否必须发送一条消息说图像已经结束?

2 个答案:

答案 0 :(得分:1)

docs 说:

Hex 1D 76 30 m xL xH yL yH d1....dk

m 为 0x48..0x51,因此您无法发送

1D 76 30 30 20 00 00 01

而是,例如

1D 76 30 48 20 00 00 01

我认为 xHyL 为 0 没有多大意义。

答案 1 :(得分:0)

我记得有<ESC>K(不是GS)命令来打印8行像素。有关详细信息,请参阅ESC命K必须发送2个字节 - 数据字节数和实际数据。但无法保证每台打印机是否都支持此功能。您的品牌和型号是什么?