Skip to content

Instantly share code, notes, and snippets.

@seokju-na
Last active June 24, 2022 13:18
Show Gist options
  • Save seokju-na/010ce4931254181747091b58ec382ce6 to your computer and use it in GitHub Desktop.
Save seokju-na/010ce4931254181747091b58ec382ce6 to your computer and use it in GitHub Desktop.
react-thermal-printer
const port = new SerialPort('COM1', {
baudRate: 9600
});
const receipt = await renderToBuffer(
<ThermalPrint type="EPSON" width={42} characterSet="KOREA">
<ThermalPrint.Txt size={{ width: 1, height: 1 }}>10,000원</ThermalPrint.Txt>
<ThermalPrint.Txt>결제 완료</ThermalPrint.Txt>
<ThermalPrint.Br />
<ThermalPrint.Line type="single" />
<ThermalPrint.Row left="결제방법" right="체크카드" />
<ThermalPrint.Row left="카드번호" right="123456**********" />
<ThermalPrint.Row left="할부기간" right="일시불" />
<ThermalPrint.Row left="결제금액" right="10,000" />
<ThermalPrint.Row left="부가세액" right="909" />
<ThermalPrint.Row left="공급가액" right="9,091" />
<ThermalPrint.Line type="single" />
<ThermalPrint.Row left="정말 맛있는 옥수수수염차 X 2" right="11,000" />
<ThermalPrint.Txt>옵션1(500)/옵션2/메모</ThermalPrint.Txt>
<ThermalPrint.Row left="(-) 굉장히 엄청난 할인" right="- 6,000" />
<ThermalPrint.Br />
<ThermalPrint.Line type="single" />
<ThermalPrint.Row left="합계" right="10,000" />
<ThermalPrint.Row left="(-) 깜짝 할인 2%" right="- 1,000" />
<ThermalPrint.Line type="single" />
<ThermalPrint.Row left="대표" right="김대표" />
<ThermalPrint.Row left="사업자등록번호" right="000-00-00000" />
<ThermalPrint.Row left="대표번호" right="0000-0000" />
<ThermalPrint.Row left="주소" right="어디시 어디구 어디동 몇동몇호" />
<ThermalPrint.Line type="single" />
<ThermalPrint.Br />
</ThermalPrinter>
);
port.write(receipt);
@seokju-na
Copy link
Author

seokju-na commented Jun 24, 2022

aaa.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment