How can I programmatically get a preview of a label from NiceLabel?

Getting a preview of a label from NiceLabel is quite easy. All you have to do is call GetLabelPreviewEx method of the INiceLabel interface. GetLabelPreviewEx has 6 parameters:

  • file name: full path to the file where NiceLabel will generate image of the label. Extension part of the file name defines which graphics format will be used. You can use .bmp, .jpg, .png or .gif as the file name extension. 
  • width: width of image (in pixels) 
  • height: height of image (in pixels) 
  • label kind: there are 3 possible values that define the kind of label you want preview for; 0 – header label, main label, tail label 
  • label side: define whether you want to preview front side (use 0 as parameter value) or back side of the label (use 1 as value). Using back side of the label makes sense only if you have label designed as double sided.
  • flag that defines whether to show border around preview or not (true or false) 

Function will return true if graphics file was successfully created or false it file could not be created.


bool GetLabelPreviewEx(fileName, width, height, labelKind, labelSide, showBorder)


The following code will run NiceEngine, open label and get a preview of the label in a file called “preview.jpg” that is located in “c:\tmp”. Then you can load the image file in a component of your choice.


// Open NiceEngine
NiceEngine5WR.NiceApp engine = new NiceEngine5WR.NiceApp();
// Open label
NiceEngine5WR.NiceLabel label = engine.LabelOpenEx(“file.lbl”);

string previewFileName = @"c:\tmp\preview.jpg";
int width = 640;
int height = 480;
previewStatus = label.GetLabelPreviewEx(previewFileName, width, height, 1, 0, false);
Posted in NiceLabel, SDK Tagged with: , , , ,