Search code examples
escpos

Vertical Spacing in ESC/POS


I'm printing an adhesive label (6x5cm) with a printer model 3nStar RPT006.

In the adhesive I am printing a title, QR code and the QR code in text

something like this

My Title

qr code

Using this class as reference, I'm doing something like this:

initialize(),
setJustification(Printer.JUSTIFY_CENTER),
'My Title',
feed(),
qr(qrText),
feed(),
qrText,
feed(2),
cut(Printer.CUT_FULL, 1),

My problem is: I don't know how to control the vertical size, or how to set the height of the paper. Between each label I have a gap of 3mm.

So my question is, how should I handle the vertical spacing/height?

Currently I very close to get a perfect label, but seems like the printed label is some millimeters shorter and each time I print a label, it miss a little bit more, so there is a time where I start to cut the adhesive part and not the gap


Solution

  • I'm not sure if it's possible in your environment, but there are three options.

    • Prepare blank image data with the required number of vertical dots and print it(graphics(EscposImage $image, $size)) instead of the line feed code.
    • Use setLineSpacing($height) to change the height of one line only for the required part and start a new line. Then return to the original size.
    • Make your own customization by adding the function to feed the paper in dot units to the library for printing.
      ESC J