qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
834 stars 272 forks source link

I'm able to print Barcode type EAN13 but not ITF (Interleaved 2 of 5) #892

Open astrO1 opened 2 years ago

astrO1 commented 2 years ago

First of all, thank you for this amazing plugin.

now for the question, i have a helper class for ESC/POS command that is this:

export class PrintCommands {

    // Feed control sequences
    public static INI_PRINT = '\x1B' + '\x40';
    public static ALIGN_TO_CENTER = '\x1B' + '\x61' + '\x31';
    public static ALIGN_TO_LEFT = '\x1B' + '\x61' + '\x30';
    public static LINE_BREAK = '\x0A';

    public static SMALL_TEXT = '\x1B' + '\x4D' + '\x31';
    public static NORMAL_TEXT = '\x1B' + '\x4D' + '\x30';

    public static BOLD_TEXT_ON = '\x1B' + '\x45' + '\x0D';
    public static BOLD_TEXT_OFF = '\x1B' + '\x45' + '\x0A';

    public static BARCODE_HEIGHT = '\x1D' + '\x68' + '\x64';
    public static BARCODE_WIDTH = '\x1D' + '\x77' + '\x00';
    public static BARCODE_EAN13 = '\x1D' + '\x6B' + '\x02';
    public static BARCODE_ITF = '\x1D' + '\x6B' + '\x05';

    public static FULL_CUT_PAPER = '\x1D' + '\x56'  + '\x00';
    public static PARCIAL_CUT_PAPER  = '\x1D' + '\x56'  + '\x01';

}

and this is my printing function:

    PrintCommands.ALIGN_TO_CENTER,
    PrintCommands.LINE_BREAK,
    PrintCommands.BARCODE_HEIGHT,
    PrintCommands.BARCODE_WIDTH,
    // PrintCommands.BARCODE_EAN13 ,
    PrintCommands.BARCODE_ITF,
    "9876543210",
    "9876543210" + '\x0A',
    PrintCommands.LINE_BREAK,

What i'm doing wrong? When i remove the comment line and use EAN13 it works fine but when i put ITF nothing is printed. I know this is not about you plugin but i think you guys have a better experience than me about this commands.

After some search i see this in github:

//barcode data
var code = '12345';

//convenience method
var chr = function(n) { return String.fromCharCode(n); };

var barcode = '\x1D' + 'h' + chr(80) +   //barcode height
    '\x1D' + 'f' + chr(0) +              //font for printed number
    '\x1D' + 'k' + chr(69) + chr(code.length) + code + chr(0); //code39

qz.websocket.connect().then(function() {
   var config = qz.configs.create("Epson TM88V");
   return qz.print(config, ['\n\n\n\n\n' + barcode + '\n\n\n\n\n']);
}).catch(function(err) { alert(err); });

I'm able to reproduce this code39 example perfectly in my print, i just want a similar example for Interleaved 2 of 5 ( ITF ) .

lite1979 commented 2 years ago

It looks like you're using for both ITF and EAN13, whereas our example uses for code39, so it's not a direct comparison, but I can get working on an example that will use for your ITF barcode instead. I'll just need a few days.

I did notice that you didn't include a \x00 after your numerical data, though, and the GS k page in the ESC/POS manual calls for it for any barcode. When you scan the barcode you printed for EAN13, do you get all of the data, or is the zero missing?

https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=128

Sorry I can't be of more help right away; I need to get back in practice to give you a definitive answer, but I think you're just missing something from the barcode spec.

astrO1 commented 2 years ago

Hi @lite1979, thanks for the answer.

I managed to work using BARCODE_EAN13, full code with no zero missing.

public static BARCODE_EAN13 = '\x1D' + '\x6B' + '\x02';

Now i want to make a ITF version of the code, how can i do that?

tresf commented 2 years ago

Hi @lite1979, thanks for the answer.

I managed to work using BARCODE_EAN13, full code with no zero missing.

public static BARCODE_EAN13 = '\x1D' + '\x6B' + '\x02';

Now i want to make a ITF version of the code, how can i do that?

@lite1979 can you please provide an update on this?

tresf commented 1 year ago

@astrO1 did you ever figure this out? This should be possible using the document link that Lite sent above.