node-escpos icon indicating copy to clipboard operation
node-escpos copied to clipboard

Encode picture

Open Nehved opened this issue 6 years ago • 6 comments

Hi there. I have some troubles with printing images. Here my source code `const device = new escpos.Network(IP); const options = { encoding: 'CP860' }; const printer = new escpos.Printer(device, options); const tux = path.join(__dirname, 'tux.png');

escpos.Image.load(tux, (image) => { device.open(() => { printer.text('hello here'); printer.image(image); printer.cut(); printer.close(); }); });`

below I attached photo of result, thanks for your help)

photo_2019-12-17_18-02-05

Nehved avatar Dec 17 '19 15:12 Nehved

Btw, I use Ubuntu 18.04 + Electron app, printer HP.

Nehved avatar Dec 17 '19 15:12 Nehved

printer.image is an async method https://github.com/song940/node-escpos/blob/master/printer.js

Psychopoulet avatar Dec 18 '19 10:12 Psychopoulet

@Psychopoulet thanks for response, I refactored my code in next way:

const { Printer, Network, Image } = require('escpos');
const device = new Network(ip);
const printer = new Printer(device);
const tux = path.join(__dirname, 'tux.png');

Image.load(tux, (image) => {
  device.open(async () => {
    await printer.image(image);
    printer.cut().close();
  });
});

result still the same, could you pls provide working example?

Nehved avatar Dec 18 '19 14:12 Nehved

... in your electron app do you use this package in a front way ??

Psychopoulet avatar Dec 19 '19 10:12 Psychopoulet

@Psychopoulet no, it is located in my main file for backend part, like "electron.js"

Nehved avatar Dec 19 '19 12:12 Nehved

what is your printer's model ? are you sure thate escpos standard is enable on it ?

Psychopoulet avatar Dec 20 '19 09:12 Psychopoulet