1

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

Image

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?

6
  • increase width of each and make right alignment to all will fix your issue Commented Sep 6, 2016 at 7:06
  • my requirement is left side quantity and product name should come and price should be displayed to right of page Commented Sep 6, 2016 at 7:15
  • 1
    try this in with out this condition if ProductName.characters.count > 13 Commented Sep 6, 2016 at 9:35
  • 1
    @KrutarthPatel - I worked on this concept, but Eposn has one option for alignment option , please check once Commented Sep 6, 2016 at 9:38
  • Can you show me code in swift ? Commented Sep 6, 2016 at 9:39

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for response.will check
@KrutarthPatel - finally we do for little bit changes in space in that your code, sorry I also did this in 1 year back I forgot most of the things
means.where you change
@KrutarthPatel - in this one strtext.appendString(String (format: "%@ %@ %@\n", sQuantity,subStr,s))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.