JsBarcode
JsBarcode copied to clipboard
Printing Barcodes
Hi,
I have gone through quite a few of the issues listed in this repo and I know this is a frequent question that keeps coming up. However, there doesn't seem to be an accepted practise while printing the generated barcodes onto a barcode label.
I am using a TSC TTP-244 Pro printer (link) with a barcode label size of 2 x 4 inches (height is 2 inches and width is 4 inches).
I am struggling to figure out how to format the barcode size and my HTML correctly to get the labels to print correctly. What is currently happening is that the barcodes cross the label boundaries. I've attached an image exhibiting the problem.
What I am looking for is to understand what the accepted practise of trying to get this to work is.
Is it to:
- Create a PDF of the barcodes using a library like jsPDF with each individual barcode added as an image of 2 x 4 in?
- Create HTML using SVG and render the barcodes and format the HTML using CSS somehow to get the barcodes to print correctly?
I'm doing it using @react-pdf/renderer and JsBarcode. @react-pdf/renderer won't take in an image or svg so I create a canvas and then change that to a DataURL and pass that back to the image component in @react-pdf/renderer.
It works well. Still trying to figure out what controls the actual width of the barcode, it seems to fill the width of my label no matter what. So 3 digits fills the width and so does 20 digits. Not sure it matters but it is a little odd.
我也在做打印,不清楚你是否已解决,但是你这个问题应该或许 更改下 打印机的设置纸张设置 还有在打印时,设置好传过来的纸张大小
Hi, i have same issue, have you decided problem?
Could you send html and css for print page?