2

I need to draw a horizontal line (solid one but dashed will be perfect!) to my receipt using ESC/POS commands.

Now I'm using some hack that allow me to draw a horizontal line by using "UnderLine" command with some space characters, but i don't like it because i need to give the line some drawing properties like a "Height":

PRINT #1, CHR$(&H1B);"-";CHR$(1); <==== set underline on
PRINT #1, "            "; CHR$(&HA);
PRINT #1, CHR$(&H1B);"-";CHR$(0); <==== set underline off

I believe it can be happen with bit image commands but i have no idea how to do that.

Thanks in advance

Top Systems
  • 951
  • 12
  • 24
  • Wouldn't a dashed line just be `"--------------"`? Or maybe `"- - - - - - - - - -"`? – nneonneo Mar 10 '13 at 13:26
  • whats wrong with just printing underscores? chr$(95) – Hazzit Mar 10 '13 at 13:26
  • Yes, that's the easiest way, but I need it to print automatically in full width. And also need to give the line a height. – Top Systems Mar 10 '13 at 13:35
  • @Muhammad did you managed to find a good solution? I need to draw line across the page (left to right). The trouble is, I do not know how many "dash" (or "space" if using underline) should I use. Right now, it is a manual process – Sam Apr 26 '18 at 16:15

4 Answers4

1

An old question, but I also struggled with it recently.

Most receiptprinters still have the old codepages like PC850, PC858, PC1119 etc. And most of those pages have the old DOS box characters (like ╚ ╬ ┬ ┐).

The easiest way to print a line I found is to use character(196) and just repeat it n times to get ─────.

In this oldfashioned way you can also print boxes etc.

Michel
  • 4,076
  • 4
  • 34
  • 52
1

Using mike42's escpos-php:

$printer->textRaw(str_repeat(chr(196), 40).PHP_EOL);
William
  • 166
  • 1
  • 4
0

Another way to print special graphics is use the bit image command 0x1B 0x2A (ESC *) Then set the number of bits across the page, then generate an 8-bit high by xx bytes wide pixel map. the 8-bits are represented by MSB (top) to LSB (bottom) so a solid 8-pixel high line is 0xFF. I often use data bytes 0x80 to draw a 1-pixel line, or 0x01 to put the line on the bottom. Also, you could reference this article: http://nicholas.piasecki.name/blog/2009/12/sending-a-bit-image-to-an-epson-tm-t88iii-receipt-printer-using-c-and-escpos/ Have fun.

IrvineCAGuy
  • 211
  • 2
  • 12
-2

You have to go in page mode, and set the char spacing to 0 + use a small font size and probably bold style so that there is no more space between the underscores. To set the line height, the only solution is to draw several lines stacked on top of each other. This is possible in page mode as you can place the data wherever you want using print area (ESC W).

Another possible trick is to use logos to draw the lines (still in page mode)

tomrozb
  • 25,773
  • 31
  • 101
  • 122
Seb
  • 1