thiendangit / react-native-thermal-receipt-printer-image-qr

React native thermal receipt printer
https://www.npmjs.com/package/react-native-thermal-receipt-printer-image-qr
111 stars 73 forks source link

About the "printColumnsText" method #109

Open tanerparcali opened 11 months ago

tanerparcali commented 11 months ago

"printColumnsText" also used in the method let columnWidth = [46 - (7 + 12), 7, 12]; what does it mean. let's say I have an 80mm printer and I want to print a triple table and I want the division to be "3 / 1 / 2" so a long left field, a short center field and a slightly longer right field.

How should columnWidth be set in this case?

Thanks.

licomobrusli commented 8 months ago

You probably reslved this a long time ago but anyway ...

In the example the whole text row allows 46 characters. The author wants the 2nd column to have 7 and the third column to have 12 and the first column to have all the rest i.e. 46 - (7+12). Therefore using up all 46 characters. This is an example where the programmer knows the character limit of a row (46) and that column 2 and 3 will never have more than 7 and 12 characters respectively and wants his column 1 to have all of the remaining characters.

If you want the division to be 3 / 1 / 2 then you need to know the length of your row in characters (X) and then do [X (3/6), X (1/6), X * (2/6)];