收据对齐在swift中无法正常工作 [英] Receipt alignment is not working properly in swift

查看:143
本文介绍了收据对齐在swift中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在打印我的数据
的收据,当我打印我的收据时,对齐数据无法正常工作

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

这里是收据的截图

你可以看到收据对齐错误

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?

推荐答案

您的代码还可以,
Epson中的选项打印机

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
};

该方法被调用为 - (int)addTextAlign:(int)align ; 使用对齐类型作为中心并尝试一次

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

这篇关于收据对齐在swift中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆