Search code examples
thermal-printerescposqz-tray

How to declare size in qz-tray Esc/pos rawprinting?


i'm Using qz-tray raw printing ESC/POS. i can't set Size of the Image data..

How to set size(width and height) of the image format without affect other data.?

code:

var config = qz.configs.create("Printer Name");

var data = [
   { type: 'raw', format: 'image', flavor: 'file', data: 'assets/img/image_sample_bw.png', options: { language: "ESCPOS", dotDensity: 'double' } },
   '\x1B' + '\x40',          // init
   '\x1B' + '\x61' + '\x31', // center align
   'Beverly Hills, CA  90210' + '\x0A',
   '\x0A',                   // line break
   'www.qz.io' + '\x0A',     // text and line break
   '\x0A',                   // line break
   '\x0A',                   // line break
   'May 18, 2016 10:30 AM' + '\x0A',
   '\x0A',                   // line break
   '\x0A',                   // line break    
   '\x0A',
   'Transaction # 123456 Register: 3' + '\x0A',
   '\x0A',
   '\x0A',
   '\x0A',
   '\x1B' + '\x61' + '\x30', // left align
];
qz.print(config, data);

if i have set size in config file couldn't change the image size.but if only use image formate without othe rdata it has changed. as well as i need 2 copies without changed align.


Solution

  • How to set size(width and height) of the image format without affect other data.?

    You can't. QZ Tray will send the raster data exactly as it's provided. Resizing will often result in aliasing, which results in a much degraded quality. This degraded quality is even more noticeable on a low-dpi (e.g. 180 dpi) printer.

    You will need to properly size the image before providing it to the QZ Tray API.