lukevp / ESC-POS-.NET

Efficient, Easy to Use Thermal Printing & POS (Windows/Linux/OSX, WiFi/BT/USB/Ethernet)
MIT License
530 stars 178 forks source link

Looping through items #172

Open Elvis3107 opened 2 years ago

Elvis3107 commented 2 years ago

Thanks for this, I can't really explained how you saved my life. Been trying to print receipt for the past months before I saw this.

I successfully implemented and can print but am unable to loop through a list or rather am unable to print elements from a list dynamically, can you PLEASE HELP.

I tried a couple of things and nothing worked so far, I tried looping and putting the data in a string but the break line doesnt work, I tried creating multiple byte arrays but that didnt work either. PLEASE HELP

Thank you

Elvis3107 commented 2 years ago

Thanks for this, I can't really explained how you saved my life. Been trying to print receipt for the past months before I saw this.

I successfully implemented and can print but am unable to loop through a list or rather am unable to print elements from a list dynamically, can you PLEASE HELP.

I tried a couple of things and nothing worked so far, I tried looping and putting the data in a string but the break line doesnt work, I tried creating multiple byte arrays but that didnt work either. PLEASE HELP

Thank you

Found a way

ByteArrayBuilder bab = new ByteArrayBuilder();

        foreach (var item in orderWithItems.orderItems)
        {
            bab.Append(Encoding.ASCII.GetBytes(item.productName + " \n"));
        }
        byte[] data = bab.ToArray();