GDI+ - Standard Format for removable labels - Asked By Erik Little on 05-May-13 12:09 PM

Is there a standard format that developers use when it come to telling their customers which labels to purchase from a store like office max or office depot?

Is there a set standard paper with sticky labels that is adopted by .net c# developers? 

Are is there a standard (generic) width paper that fits into a standard printer with the same amount of columns and same amount of rows that if I am to just choose one at office max or walmart that the different type are so similar that the customer could find the paper with labels just about anywhere that would work with the formatting that I'm going to use.

I've attached a photo of a snapshot of a page of labels that will work perfectly and or something similar.

I'll be use the Graphics device and bitmap to draw in windows forms.

Like for the example below if I was to write my code that would center the text inside each label would it be easy for a customer to find another label provider, "Or just run up to the closest store like office max, office depot, or walmart and just grab a paper with sticky labels" that would most likely  work with the formatting I've used, that is if I keep the column and rows the same?


Anyone got experience with this? 

What I do not what to do is format my drawing program to fit only one brand of label makers.

Erik

Robbe Morris replied to Erik Little on 05-May-13 01:17 PM
There is no standard and your customers are going to try all sorts of products.  While it is a pain, I would suggest adding functionality in your program to enable customers to create a paper product profile to use at print time.  You'd let them position the label as well as increase/decrease font sizes. 
Erik Little replied to Robbe Morris on 05-May-13 04:36 PM
Thank you Robbe.

You know if it wasn't for you guys I wouldn't be where I'm at today! I'm just now really getting it on the .net end and the sql end!

You guys are awesome!

Erik
Robbe Morris replied to Erik Little on 05-May-13 05:19 PM
Here's some code for drawing the label using a Graphics object on your form.  The second argument for new PointF is the "y" or top position.  You'd want to use a variable like "left" below and set a "top" variable.  Then, on each line, you add x for the line height and a little buffer space.  In your UI, you could let the user adjust the left and top variable volumes prior to printing.  Of course, you'd want them to be able to store those values and automatically use them next time.

var font = new Font("Arial", 12.0f);
var fontColor = Brushes.Black;
float left = 10.0f;

e.Graphics.DrawString("line 1 text", font, fontColor, new PointF(left, 10.0f));
e.Graphics.DrawString("line 2 text", font, fontColor, new PointF(left, 30.0f));
e.Graphics.DrawString("line 3 text, font, fontColor, new PointF(left, 50.0f));
e.Graphics.DrawString("line 4 text", new Font("Arial", 16.0f), fontColor, new PointF(left, 80.0f));
e.Graphics.Dispose();

Erik Little replied to Robbe Morris on 05-May-13 05:50 PM
Thank you.
Erik Little replied to Robbe Morris on 10-May-13 05:49 PM
I've got a couple of questions related to converting inches to pixels and how that relates to a standard 8.5" x 11" sheet of paper that these labels or on.

The current labels that I'm writing on are on a standard paper 8.5 x 11 with 3 columns and 10 rows.

Each label is 1"height x 2 5/8"width

I've started this out by creating a SheetInfo class.

When I create my Bitmap that I'm calling Sheet is it necessary to set the width and height of the Bitmap "Sheet" to be oversized like I'm noticing others mentioning on the net. They're saying set the sheet to 1700 x 2200 pixels so that the user can choose fit to page when printing, and this will produce a better quality print.

The thing that is throwing me off is when I drawstring to a label in a loop then i get to the very next label in the same row but the next column I need the formula to write the text correctly, since I'm not writing to an oversized Bitmap.


Heres what I've got:

   public class SheetInfo
   {
     public byte Columns { get; set; }
     public byte Rows { get; set; }
     public decimal ContentWidth { get; set; }
     public decimal ContentHeight { get; set; }
     public short SheetWidth { get; set; }
     public short SheetHeight { get; set; }
 
     public SheetInfo() { }
     public SheetInfo(byte columns, byte rows, decimal contentWidth, decimal contentHeight, short sheetWidth, short sheetHeight)
     {
       this.Columns = columns;
       this.Rows = rows;
       this.ContentWidth = contentWidth;
       this.ContentHeight = contentHeight;
       this.SheetWidth = sheetWidth;
       this.SheetHeight = sheetHeight;
     }
   }
 
 SheetInfo sinfo = new SheetInfo(3, 10, 2.6250m, 1, 1700, 2200);
 
sheets = ContentContainers.GetLabels(this.Optimized.OrderBy(o => o.CutPart.PartNumber).ToList<IGroupedPart>(), sinfo);
 
 
  public static List<Bitmap> GetLabels(List<IGroupedPart> optimized, SheetInfo sheetInfo)
     {
       int totalParts = optimized.Count();
       byte currowCnt = 0,
        currColumnCnt = 0;
 
       float left = 10.0f,
         margin = 10.0f,
         startX = margin + left,
         startY = margin + left;
 
       List<Bitmap> sheets = new List<Bitmap>();
 
       using (var f = new Font(DrawingOptions.DETAIL_BOX_FONT.FontFamily, 12))
       {
         var sheet = new Bitmap(sheetInfo.SheetWidth, sheetInfo.SheetHeight);
 
         using (var dc = Graphics.FromImage(sheet))
         {
           for (short i = 0; i < totalParts; i++)
           {
             string len = optimized[i].CutPart.Length.ToString("N4"),
                nm = optimized[i].CutPart.Name;
             int cnt = optimized[i].Total;
 
             for (int ii = 0; ii < cnt; ii++)
             {
 
               dc.DrawString("line 1 text", f, Brushes.Black, new PointF(startX, startY));
 
               startX = margin + left + ((float)sheetInfo.ContentWidth * (i + 1));
 
               currColumnCnt += 1;
 
               if (currColumnCnt == sheetInfo.Columns/*new row needed*/)
               {
                 startY = margin + left + ((float)sheetInfo.ContentHeight * (i + 1));
               }
 
 
               if ((i + 1) == sheetInfo.Rows/*new sheet needed*/)
               {
                 //
               }
               else
               {
                 //  startY = margin + left;
               }
             };
           };
 
           sheets.Add(sheet);
         };
 
       };
 
       return sheets;
     }



When creating a new SheetInfo-> new SheetInfo(3, 10, 2.6250m, 1, 1700, 2200); the 2.6350m and the 1 are both inches I need for those to be converted to match the oversized Bitmap 1700 x 2200 px.

And also, for my loop, --> startX = margin + left + ((float)sheetInfo.ContentWidth * (i + 1));
Are there a couple of variables that I can set to add to the X and Y poistions that will relate to the oversized Bitmap "Sheet"?


Thanks
Erik




Robbe Morris replied to Erik Little on 10-May-13 05:59 PM
I looked at the code in here and it looks like something you could work from:

http://sourceforge.net/projects/labelprintapi/files/

The appear to have tackled the issue of different sizes of labels across multiple columns.