I'm building a POS on iPad using swift to print to Epson printers over ethernet connection.
I'm using Epson docs and sample projects to have the printers up and running no problem.
Now heres the problem:
I need to change text size (bigger) then revert back to original text size - I can initially change textSize no problem -> but when I revert back to the original size it does get smaller but it is not as small as the original. See below:
According to Epson docs - addTextSize()
- is the method I am looking for and it accepts an Int value between 1-8 to scale both height and width (it states that 1 is the default value)
So here is my code:
func sendPrint(printer: Epos2Printer) -> Bool {
var result = EPOS2_SUCCESS.rawValue
let textData: NSMutableString = NSMutableString()
result = printer.addFeedLine(2)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addFeedLine")
return false
}
textData.append("Food item $12.00\n")
textData.append("Food item $12.00\n")
textData.append("Food item $12.00\n")
textData.append("Food item $12.00\n")
// SEND AT ORIGINAL TEXT SIZE (Should be 1,1)
result = printer.addText(textData as String)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addText")
return false
}
textData.setString("")
// CHANGE TEXT SIZE BIGGER WIDTH (2,1)
result = printer.addTextSize(2, height:1)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addTextSize")
return false
}
textData.append("ADDRESS \n")
textData.append("CITY \n")
textData.append("STATE \n")
textData.append("ZIPCODE \n")
result = printer.addText(textData as String)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addText")
return false
}
textData.setString("")
// CHANGE TEXT SIZE BACK TO DEFAULT (1,1)
result = printer.addTextSize(1, height: 1)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addTextSize")
return false
}
textData.append("Food item $12.00\n")
textData.append("Food item $12.00\n")
textData.append("Food item $12.00\n")
textData.append("Food item $12.00\n")
result = printer.addText(textData as String)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addText")
return false
}
textData.setString("")
result = printer.addFeedLine(2)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addFeedLine")
return false
}
result = printer.addCut(EPOS2_CUT_FEED.rawValue)
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"addCut")
return false
}
printer.beginTransaction()
result = printer.sendData(Int(EPOS2_PARAM_DEFAULT))
if result != EPOS2_SUCCESS.rawValue {
printer.clearCommandBuffer()
MessageView.showErrorEpos(result, method:"sendData")
printer.disconnect()
return false
}
printer.endTransaction()
return true
}
Now I know a workable option is to set the textSize from the beginning - but I would prefer to keep the top and bottom the smallest size possible.
I have also tried specifying EPOS2_PARAM_DEFAULT
as a parameter which produces the same results - I've tried 0 as the input which causes the textSize change to fail - I tried using a double like 1.5 or .5 but that doesn't compile
Any ideas?
Thanks for your help!