seokju-na / react-thermal-printer

React for thermal printing
MIT License
298 stars 42 forks source link

Will it Work for Multiple printers #58

Closed unaisshemim closed 11 months ago

unaisshemim commented 1 year ago

Will the module support to print the receipt into multiple printers simultaneously

seokju-na commented 11 months ago

Yes. you can send print data into multiple printers.

Example codes in Node.js:

import { SerialPort } from 'serialport';
import { Printer, Text, Cut, render } from 'react-thermal-printer';

const data = await render(
  <Printer type="epson">
    <Text>Hello World</Text>
    <Cut />
  </Printer>
);

const port1 = new SerialPort({ path: 'COM1', baudRate: 9600 });
const port2 = new SerialPort({ path: 'COM2', baudRate: 9600 });

port1.write(Buffer.from(data));
port2.write(Buffer.from(data));