Open GabrielMobileQD opened 3 years ago
i think we just write function get length of content left and content right and subtract for total length 1 row is 42 char. and we have content 1 line = ${contentLeft}${space}${contentRight}
space is result when we subtract length content left and content right .
@lehuyroxyproduction Thanks for your answer! But i didn't understand how your answer can solve my problem. Can you explain to me in a better way?
This is my example
let SPACE_DEFAULT = 42
const ContentBill= (left?:String,right?:String)=>{
let contentLeft = left
let contentRight = $${parseFloat(right).toFixed(2)}
let leftLen = contentLeft.length
let rightLen = contentRight.length
let spaceLen = SPACE_DEFAULT - leftLen - rightLen
let space=''
for(let i = 0; i <spaceLen; i++ ){
space = space + ' '
}
return ${contentLeft}${space}${contentRight}
}
try {
await NetPrinter.printBill(${ContentBill( 'Service' , '45' )}
)
}catch (err) {
console.warn(err);
}
@GabrielMobileQD is this printText works for you?
await Printer.printText("
I tried it in my app the text doesn't print, it only a plan paper
Thanks @lehuyroxyproduction for writing the function for me, i'm gonna use it in my project to see if it works correctly! Yes @hasithaWalpola , for me it works! It's only happening the issue that I described above! Please say more details about your problem, i'll help in what i can asap! :)
Thanks @GabrielMobileQD yeah it works for me, the issue is with my printer encoding type. Is there way to add margins and align the text?
You're welcome! You can align the text using the tags described in this lib doc, as you can see in the image below:
And i discovered by myself looking the lib code that you can align the text to the left using the tag
Any update on this? I am facing the same issue
In my case, All other pre-defined tags except "C" are not working in iOS.
@HeligPfleigh In my case, except "C" tag all other predefined tags are not working in IOS. Can you suggest any workaround for font size please.
@vatsal-gadhiya-searce @LukhiKartik this is why it's not working. because they dont have such feature 😂 in they code for iOS they replace all the tags before insertion
@mjm918 I know their code :). But asking for any workaround to use different font-sizes and bold tags?
Does anyone have an idea for applying font size or left or right alignment for IOS? I am facing this issue too
Does anyone have an idea for applying font size or left or right alignment for IOS? I am facing this issue too
Currently left and right I use the way is to count characters to format left and right. With a total of 1 line is 42 characters. then calculate the number of characters of the content minus the sum of 1 line characters and the remaining line number of characters insert the number of spaces
When i run the following piece of code:
But, when i run in IOS it does not works correctly as you can see in the image below:
So what do i need to do to solve this problem?
await Printer.printText("<C>#3</C>\n<C>SUBWAY</C>\n<L>Nome:Joao Felipe Fonseca Nascimento</L>\n<L>Celular: +55 79 9 9685-9817</L>");
In Android works correctly as you can see in the image below, the formatting is totally correct:Thanks, Your lib is helping me a lot! Please solve my problem rsrs. I gave a star to you :).