public ThermalLabel GeneratePartLabel(string PartID, string partDescription) { //Define a ThermalLabel object and set unit to inch and label size ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 2, 1); tLabel.GapLength = 0.2; //Define a TextItem object TextItem txtItem = new TextItem(0.1, 0.25, 1.75, 0.25, "PN | " + PartID); txtItem.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontB; //txtItem.RotationAngle = 90; txtItem.Font.Unit = FontUnit.Point; txtItem.Font.Size = 10; txtItem.TextAlignment = TextAlignment.Center; //Define a TextItem object TextItem txt2 = new TextItem(0.03, 0.15, 1.9, 0.125, "DESIGN SYNTHESIS"); txt2.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontS; //txt2.RotationAngle = 90; txt2.Font.Unit = FontUnit.Point; txt2.Font.Size = 4; txt2.TextAlignment = TextAlignment.Center; //A simple vertical line LineShapeItem l3 = new LineShapeItem(1.85, 0.1, 0.01, 0.870); l3.StrokeThickness = 0.05; l3.Orientation = LineOrientation.Vertical; //A simple vertical line LineShapeItem l2 = new LineShapeItem(0.105, 0.1, 0.01, 0.870); l2.StrokeThickness = 0.05; l2.Orientation = LineOrientation.Vertical; //Define a BarcodeItem object BarcodeItem bcItem = new BarcodeItem(0.5, 0.4, 1.0, 0.5, BarcodeSymbology.Code39, PartID); bcItem.AddChecksum = false; bcItem.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontS; bcItem.Font.Unit = FontUnit.Point; bcItem.Font.Size = 4; bcItem.CodabarStopChar = CodabarStartStopChar.A; bcItem.BarHeight = 0.375; bcItem.BarWidth = 0.0104; bcItem.BarcodeAlignment = BarcodeAlignment.MiddleCenter; //Add items to ThermalLabel object... tLabel.Items.Add(bcItem); tLabel.Items.Add(txtItem); tLabel.Items.Add(txt2); tLabel.Items.Add(l3); tLabel.Items.Add(l2); return(tLabel); }
private ThermalLabel GenerateAdvancedThermalLabel() { //Define a ThermalLabel object and set unit to inch and label size ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3); tLabel.GapLength = 0.2; //get ThermalLabel SDk install dir and get the sample images string imgFolder = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Neodynamic\\SDK\\ThermalLabel SDK 6.0 for .NET\\InstallDir").GetValue(null).ToString() + "\\Samples\\Images\\"; //Define an ImageItem for AdventureWorks logo ImageItem awLogo = new ImageItem(0.1, 0.1); awLogo.SourceFile = imgFolder + "adventureworks.jpg"; awLogo.Width = 1.5; awLogo.LockAspectRatio = LockAspectRatio.WidthBased; awLogo.MonochromeSettings.DitherMethod = DitherMethod.Threshold; awLogo.MonochromeSettings.Threshold = 80; //Define a TextItem for 'AW' id TextItem txtAW = new TextItem(2.8, 0.1, 1.1, 0.5, "AW"); //font settings txtAW.Font.Name = "Arial"; txtAW.Font.Bold = true; //stretch text txtAW.Sizing = TextSizing.Stretch; //border settings txtAW.BorderThickness = new FrameThickness(0.02); txtAW.CornerRadius = new RectangleCornerRadius(0.05); txtAW.TextPadding = new FrameThickness(0); //Define a TextItem for 'Model Name' TextItem txtModelName = new TextItem(0.1, 0.75, 3.8, 0.25, "Model Name: ROAD 150"); //font settings txtModelName.Font.Name = "Arial"; txtModelName.Font.Unit = FontUnit.Point; txtModelName.Font.Size = 12; //white text on black background txtModelName.BackColor = Neodynamic.SDK.Printing.Color.Black; txtModelName.ForeColor = Neodynamic.SDK.Printing.Color.White; //padding txtModelName.TextPadding = new FrameThickness(0.075, 0.03, 0, 0); //Define a TextItem for 'Model Code' (random code) TextItem txtModelCode = new TextItem(0.1, 1, 3.8, 0.25, "Model Code: " + Guid.NewGuid().ToString().ToUpper().Substring(0, 17)); //font settings txtModelCode.Font.Name = "Arial"; txtModelCode.Font.Unit = FontUnit.Point; txtModelCode.Font.Size = 12; //white text on black background txtModelCode.BackColor = Neodynamic.SDK.Printing.Color.Black; txtModelCode.ForeColor = Neodynamic.SDK.Printing.Color.White; //padding txtModelCode.TextPadding = new FrameThickness(0.075, 0.03, 0, 0); //Define a BarcodeItem for a random 'Serial Number' string serialNum = Guid.NewGuid().ToString().ToUpper().Substring(0, 8); BarcodeItem serialBarcode = new BarcodeItem(0.1, 1.25, 3.8, 0.5, BarcodeSymbology.Code39, serialNum); //Set bars height to .3inch serialBarcode.BarHeight = 0.3; //Set bars width to 0.02inch serialBarcode.BarWidth = 0.02; //disable checksum serialBarcode.AddChecksum = false; //hide human readable text serialBarcode.DisplayCode = false; //set border serialBarcode.BorderThickness = new FrameThickness(0.02); //align barcode serialBarcode.BarcodeAlignment = BarcodeAlignment.MiddleCenter; //Define a TextItem for 'Serial Num' TextItem txtSN = new TextItem(0.1, 1.75 - serialBarcode.BorderThickness.Bottom, 1.25, 0.3, "S/N: " + serialNum); //font settings txtSN.Font.Name = "Arial Narrow"; txtSN.Font.Bold = true; txtSN.Font.Unit = FontUnit.Point; txtSN.Font.Size = 12; //padding txtSN.TextPadding = new FrameThickness(0.03); //set border txtSN.BorderThickness = new FrameThickness(0.02); txtSN.TextAlignment = TextAlignment.Center; //Define a TextItem for legend TextItem txtLegend = new TextItem(txtSN.X + txtSN.Width - txtSN.BorderThickness.Right, txtSN.Y, 3.8 - txtSN.Width + txtSN.BorderThickness.Right, txtSN.Height, "This bike is ridden by race winners! Brought to you by Adventure Works Cycles professional race team."); //font settings txtLegend.Font.Name = "Arial"; txtLegend.Font.Unit = FontUnit.Point; txtLegend.Font.Size = 7.5; //padding txtLegend.TextPadding = new FrameThickness(0.03, 0, 0, 0); //set border txtLegend.BorderThickness = new FrameThickness(0.02); //Define another BarcodeItem for EAN-13 symbology BarcodeItem eanBarcode = new BarcodeItem(0.1, 2.1, 3, 0.9, BarcodeSymbology.Ean13, "0729507704739"); //Set barcode dimensions... eanBarcode.BarHeight = 0.5; eanBarcode.BarWidth = 0.02; eanBarcode.EanUpcGuardBarHeight = 0.55; //human readable text font settings eanBarcode.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontA; eanBarcode.Font.Unit = FontUnit.Point; eanBarcode.Font.Size = 5; //Define an ImageItem for NBDA logo ImageItem nbdaLogo = new ImageItem(2.9, 2.1); nbdaLogo.SourceFile = imgFolder + "nbda.jpg"; nbdaLogo.Width = 1; nbdaLogo.LockAspectRatio = LockAspectRatio.WidthBased; nbdaLogo.MonochromeSettings.DitherMethod = DitherMethod.Threshold; nbdaLogo.MonochromeSettings.Threshold = 50; nbdaLogo.MonochromeSettings.ReverseEffect = true; //Define a LineShapeItem LineShapeItem line = new LineShapeItem(0.1, 2.8, 3.8, 0.03); line.Orientation = LineOrientation.Horizontal; line.StrokeThickness = 0.03; //Add items to ThermalLabel object... tLabel.Items.Add(awLogo); tLabel.Items.Add(txtAW); tLabel.Items.Add(txtModelName); tLabel.Items.Add(txtModelCode); tLabel.Items.Add(serialBarcode); tLabel.Items.Add(txtSN); tLabel.Items.Add(txtLegend); tLabel.Items.Add(eanBarcode); tLabel.Items.Add(nbdaLogo); tLabel.Items.Add(line); return(tLabel); }