Receipt alignment is not working properly in swift

岁酱吖の 提交于 2019-12-01 10:30:31

问题


I am currently printing receipt from my data when i print my receipt alignment data is not working properly

i think that i should apply start index and end index to string

because my product name length is different So i apply this code to check length of string

here is screenshot of Receipt

you can see in receipt alignment is wrong

Here is my code to give alignment and receipt

   if       ProductName.characters.count > 13 {let subStr = ProductName[ProductName.startIndex.advancedBy(0)... ProductName.characters.count(13)]
            strtext.appendString(String (format: "%@ %@                       %@\n", sQuantity,subStr,s))
            textData.appendString(strtext as String)
        }

my requirement is first quantity,name and price should be come My receipt alignment is not proper

anyone can help me solve this issue?


回答1:


your code is fine additionally , there is the option in Epson Printer in

enum EposOcAlign {
 EPOS_OC_ALIGN_LEFT = 0,
 EPOS_OC_ALIGN_CENTER,
 EPOS_OC_ALIGN_RIGHT
};

the method is invoked as - (int) addTextAlign:(int)align; use align type as center and try once



来源:https://stackoverflow.com/questions/39342311/receipt-alignment-is-not-working-properly-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!