Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just pointing out an alternative method #70

Open
vajahath opened this issue Feb 24, 2024 · 1 comment
Open

Just pointing out an alternative method #70

vajahath opened this issue Feb 24, 2024 · 1 comment

Comments

@vajahath
Copy link

vajahath commented Feb 24, 2024

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:

  • Alignment: This is a solved problem in html. With now we having the container-queries, we can design a div the way we want.
  • Tables: html tables adjust themselves
  • Responsive: Thermal printer comes in many width - 2 inch (my case), 3 inch. With the right css you can target any number of widths.
  • Tiny and simplified code (mainly image manipulation is only required)
  • Framework agnostic.

Cons:

  • Need to fiddle around the printer dpi (mine is 200) and possible print widths.

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

@vajahath
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant