本系列教程会解答您在使用条形码生成控件TBarCode SDK产品时遇到的绝大部分疑惑。
TBarCode SDK是一款可以在任意应用程序和打印机下生成和打印所有条码的条码软件组件。TBarCode SDK对于MicrosoftOffice 用户以及软件开发者提供条码打印。使用此款条码软件组件您可以以完美效果生成和打印所有用于工业和商业条码符 。
【TBarCode SDK最新版下载】
一. 如何创建针对Thermal Printers(热敏打印机)优化的位图/strong>
VB .NET中的以下示例代码生成针对热敏打印机输出(分辨率如203 dpi)优化的条形码图像:
Dim bc As New TECIT.TBarCode.Barcode()bc.BarcodeType = TECIT.TBarCode.BarcodeType.EanUcc128bc.Data = "1234567890123"' set font sizebc.Font = New System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold, GraphicsUnit.Point)bc.TextDistance = 1.1bc.BearerBarType = TECIT.TBarCode.BearerBarType.TopAndBottombc.BearerBarWidth = 2.4' adjust quiet zone in [Modules] (recommended for bitmaps)bc.QuietZoneUnit = TECIT.TBarCode.QuietZoneUnit.Modulesbc.QuietZoneLeft = 12bc.QuietZoneRight = 12' important: set printer resolution of thermal printerbc.Dpi = 203' 203 dpi --> Module Width = 0.5005 = 4 Pixel per ModuleDim moduleWidth As New SinglemoduleWidth = 0.5004926 'need exact value here!bc.SizeMode = TECIT.TBarCode.SizeMode.CustomModuleWidthbc.ModuleWidth = moduleWidth + 0.001bc.AdjustModuleWidthToPixelRaster = TrueDim width As New SingleDim height As New Single' size in [mm]width = bc.CalculateBarcodeWidth(Nothing)height = 35' convert size to [Pixels]width = width / (25.4 / bc.Dpi)height = height / (25.4 / bc.Dpi)' adjust bitmap sizeDim drawBitmapRect As New Rectangle(0, 0, width, height)bc.BoundingRectangle = drawBitmapRect' output to filebc.Draw("barcode.bmp", TECIT.TBarCode.ImageType.Bmp)
二. 如何创建具有恒定大小的可读PDF417位图/strong>
C#ASP .NET中的以下示例代码生成具有恒定大小的PDF417图像:
//PDF417Barcode barcode = new Barcode();barcode.Data = strMyData;barcode.BarcodeType = BarcodeType.Pdf417;barcode.Pdf417.EncodingMode = PdfEncodingMode.Binary;// with dpi = 100 we get 1 Pixel = 0.254 mmsbarcode.Dpi = 100; // we should specify the number of horizontal data columns // this inhibits the symbol to change its horizontal size regardless of data barcode.Pdf417.NumberOfColumns = 16; // use a value, which fits to your available space !! // now calculate optimal bitmap size for the bar code barcode.SizeMode = SizeMode.FitToBoundingRectangle; Size optimalSize = barcode.CalculateOptimalBitmapSize(null, 1, 1); // we already could use this optimal Size for saving the image // barcode.BoundingRectangle = new Rectangle(0, 0, optimalSize.Width, optimalSize.Height); // barcode.Draw(filename, ImageType.Jpg); // but we want a constant bitmap size, // which fits exactly into your predefined space Size finalSize = new Size(350, 200); // final bitmap size in Pixel // so we have to add empty spaces around the symbol via adding a quiet zone barcode.QuietZoneUnit = QuietZoneUnit.Pixel; // calculate the required empty quiet zone we have to addif (finalSize.Width > optimalSize.Width) barcode.QuietZoneRight = finalSize.Width - optimalSize.Width;else // should not occur!! Reduce the Pdf417.NumberOfColumns finalSize.Width = optimalSize.Width; if (finalSize.Height > optimalSize.Height) barcode.QuietZoneBottom = finalSize.Height - optimalSize.Height;else // should not occur!! Increase final bitmap size finalSize.Height = optimalSize.Height;barcode.BoundingRectangle = new Rectangle(0, 0, finalSize.Width, finalSize.Height);barcode.Draw(filename, ImageType.Jpg);
三. 如何在ASP.NET Web控件中优化PDF417符 /strong>
选项1
将以下属性添加到TBarCode .NET Web Control。这将生成一个优化的符 ,适合120 x 120像素矩阵。如果需要,请增加“宽度/高度”和“NumberOfColumns”属性。
<cc2:BarcodeControl id =“BarcodeControl1” Width =“120”Height =“120” Barcode-Dpi =“96” Barcode-SizeMode =“MinimalModuleWidth” Barcode-Pdf417-NumberOfColumns =“3” Barcode-MustFit =“True”ErrorHandling =“ShowMessage” Barcode-BarcodeType =“Pdf417”
选项#2
在页面加载事件中或设置条形码数据后,应用以下计算。此代码将使用1:3的宽高比为图形模块。
Barcode barcode = BarcodeControl1.Barcode;barcode.SizeMode = SizeMode.FitToBoundingRectangle; System.Drawing.Size optimalSize = barcode.CalculateOptimalBitmapSize(null, 1, 1);BarcodeControl1.Width = new Unit(optimalSize.Width, UnitType.Pixel);BarcodeControl1.Height = new Unit(optimalSize.Height, UnitType.Pixel); BarcodeControl1.Refresh();
四. 如何创建可读代码39位图/strong>
ASP .NET中的以下示例代码生成Code 39图像:
//Code 39Barcode barcode = new Barcode();barcode.Data = "10030000007611107871900002199908";barcode.BarcodeType = BarcodeType.Code39;// with dpi = 100 we get 1 Pixel = 0.254 mmsbarcode.Dpi = 100;// bar code size should adapt to bounding rectanglebarcode.SizeMode = SizeMode.FitToBoundingRectangle;// set default size of symbol (define the default height)barcode.BoundingRectangle = new Rectangle(0, 0, 254, 100 /* = 1 inch */); // now calculate optimal bitmap size for the bar codeSize optimalSize = barcode.CalculateOptimalBitmapSize(null, 1, 1);// update rectangle to optimized sizebarcode.BoundingRectangle = new Rectangle(0, 0, optimalSize.Width, optimalSize.Height);barcode.Draw(filename, ImageType.Jpg);
五. 如何为DP Premiumadress创建26×26数据矩阵/strong>
以下C#.NET示例代码向您展示了如何调整Data Matrix的设置:
Barcode barcode = new TECIT.TBarCode.Barcode(); barcode.BarcodeType = BarcodeType.DataMatrix;barcode.DataMatrix.Size = DataMatrixSize.Square26x26;barcode.DataMatrix.Format = DataMatrixFormat.Default;barcode.DataMatrix.ShallEnforceBinaryEncoding = true;barcode.SizeMode = SizeMode.CustomModuleWidth;barcode.ModuleWidth = 0.423;barcode.EncodingMode = EncodingMode.Hexadecimal;// set preformatted data (Bytes = Hex codes)barcode.Data = "444541080D02540BE3FF0052232D242D000065000000010100015A313031000000000000000000000000";
标签:条形码条形码生成物联 工业4.0工业物联
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!