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.