lsongdev / node-escpos

🖨️ ESC/POS Printer driver for Node.js
https://npmjs.org/escpos
Other
1.37k stars 422 forks source link

Problem with center image. #124

Closed GuilhermeReda closed 2 years ago

GuilhermeReda commented 6 years ago
const escpos = require('escpos');
const device = new escpos.USB(parseInt('FFF0', 16), parseInt('0100', 16));
const printer = new escpos.Printer(device);

escpos.Image.load(__dirname + '/tux.png', function (image) {
  device.open(function () {
    printer
      .align('ct')
      .image(image)
      .cut();
  });
});

5e25745b-608b-491d-8e38-eb2d25c26ef5

mrarticuno commented 6 years ago

Fala guilherme beleza ? rapaz eu resolvi esse problema com esse codigo:

escpos.Image.load(dirImage, function(img){ window.device.open(function(){ window.printer .font('b') .align('ct') .size(1, 1) .text('\n')//48 .raster(img, 'dwdh').close(); }); });

A proposito cuidado se estiver usando impressoras EPSON, elas costumam não funcionar o print de imagens.

GuilhermeReda commented 6 years ago

This is the output. whatsapp image 2018-04-30 at 11 07 55 The image being printed is the zip below. (.png) 999999999.zip

Essa impressora é uma datecs DPP-350, na epson que tenho em casa ela funciona perfeita.

mrarticuno commented 6 years ago

Try this code and see if any of theese cmd work as intend btw

For PT-BR printing use const options = { encoding: "CP860" };// Allows you to use Special Characters as Ç ã á and so on. const printer = new escpos.Printer(device, options);

printer .align('ct')

.image(image, 's8')
.image(image, 'd8')
.image(image, 's24')
.image(image, 'd24')

.raster(image)
.raster(image, 'dw')
.raster(image, 'dh')
.raster(image, 'dwdh')

.cut();
mrarticuno commented 6 years ago

Btw, why you're not using the qrImage function from the escpos ?

GuilhermeReda commented 6 years ago

only the .image one works all the raster give me that output, and qrImage use raster.

mrarticuno commented 6 years ago

@GuilhermeReda R u using Zadig drivers ? probably after build your application will not work as intend.

GuilhermeReda commented 6 years ago

using zadig drivers. I think it's a problem to this printer. it's very limited.

mrarticuno commented 6 years ago

Probably, as I could see in the manual the commands are very limited but you can change the qrImage to Bitmap instead of raster, try read the qr-image npm repo

best of lucky for you.