seokju-na / react-thermal-printer

React for thermal printing
MIT License
292 stars 40 forks source link

Just pointing out an alternative method #70

Closed vajahath closed 3 months ago

vajahath commented 8 months ago

First, thank for your incredible work ⭐

I could keep this myself without bothering you. But seeing #64 and many others, I thought I could just open this issue.

I made a fork: https://github.com/vajahath/image-thermal-printer

What it basically does is convert the "thing to print" into an image (or HTMLCanvasElemet) and use the https://github.com/seokju-na/react-thermal-printer/blob/main/packages/printer/src/commands/image.ts image command on it.

So far, it is working nice-ish (some tweaks needed here and there)

I converted my div into canvas (https://www.npmjs.com/package/html-to-image#toCanvas). Then printed it using the above command. This gave me unlimited customization.

(the printer I'm using is very old and of low quality - hence some lines segments are lost) PXL_20240224_181001863 MP

Because the printers are generally having low resolution, serif typeface may not be a good choice. I prefer sans serif typeface. Roboto is a good choice. (Noto as well). Any font that claims to work well in low-res could be a good choice.

Some advantages I found:

Cons:


This issue was to inform you an alternative method. Feel free to close this issue whenever you wish.

vajahath commented 8 months ago

Also the https://en.wikipedia.org/wiki/Atkinson_dithering claims to provide better contrast than Floyd–Steinberg. Its integration may also provide slightly better results - just pointing out.

m90khan commented 5 months ago

Good work. I do not have any thermal printers around at the moment. so that means it can work with any thermal printer brand. It does not have to be Epson or Star. ?

@vajahath

vajahath commented 4 months ago

Thank you. Afaik, the printer itself doesn't have to be from Epson or star. Most printers I encountered (a fairly small number) do follow the Epson/star protocol. So you should be good to go. 🤞

m90khan commented 4 months ago

Thanks for your reply. helpful :)