0

I am using a zebra card printer. I'm working with a group to design a program that will allow a user to input their desired information into different boxes and print out accordingly, however there's a place in the form that allows administrative users to modify a disclaimer of sorts that will appear on the back of the card. The user can type the information into a richtextbox and it'll be stored in a database and maintained until altered if needed. The goal is to make the text print on different lines, as I'm not sure that the printer understands how to change lines and would either run off the length of the card (which is a standard credit card size) or would just continue to print each line overtop of the last. I'm pretty new to programming, the group I'm with is using visual studio and coding in c# - which I have almost no experience with, and I know very little about this printer. The issue, is that there will be a long string that the user can type in (limited to 500 characters in consolas size 12 font) and I need a way so that when a certain limit is reached the string drops down to print on the next line without chopping any words in half. I think I need to use lastIndexOf to somehow find the last space between words prior to the char limit for each line. For now, this is what's currently in place:

            foreach (string disclaimer in disclaimerSplit)
            {
                if (graphics.DrawText(x, 35, ascii.GetBytes(disclaimer), ascii.GetBytes("Consolas"), 12, fontStyle, 0x009973, out error) == 0)
                {
                    msg = "DrawText method error code: " + error.ToString();
                    return;
                }

            }

disclaimerSplit is a string array that will be used to hold each of the strings as the whole thing gets broken apart into smaller strings that will fit on each line. I'm not sure if this is overcomplicating this process or what, but I have no clue where to go with this. Use this paragraph, for example. If that were to be printed on a card, it would need to look like this. It fits in a contained space, dropping down each time a character limit is reached and no words are chopped in half between lines. Also I am using consolas font because it is monospaced and will hopefully make it easier to determine how many characters will fit per line without running off the edge of the card. I've already seen a few stack topics on this, but either they weren't exactly what I was looking for, or didn't fully make sense.

  • Identical question answered here: http://stackoverflow.com/questions/3961278/word-wrap-a-string-in-multiple-lines – RecursiveRobot Mar 10 '16 at 06:56
  • I don't think word wrap will work with the printer because each line needs to be in an array, and each array element needs to be printed just below the last. –  Mar 10 '16 at 06:59
  • Please download programming guide: https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2-pm-en.pdf – Maciej Los Mar 10 '16 at 07:03
  • I don't need the programming guide with their printer-specific language. This is a separate program that just works with the zebra printer. I am not programming the printer itself. I am just trying to make a really long string cut into an array at something like 100 characters per line/array but without cutting a word in half at the 100 character mark. It is for use with a zebra printer. That's why I need each 100 character segment stored in a separate array element. –  Mar 10 '16 at 07:14

0 Answers0