原創|使用教程|編輯:王香|2017-11-28 10:34:32.000|閱讀 980 次
概述:Spire.Barcode是一款專業的條碼組件,專為開發人員在Java應用程序(J2SE和J2EE)上生成、讀取和掃描1D、2D條形碼而設計,本文介紹了如何通過Spire.Barcode在C#中創建EAN-13條碼。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
基于UPC-A標準的EAN-13在世界范圍內用于標記零售商品。 13位EAN-13號碼由四部分組成:
代碼演示:
Step 1: 創建一個BarcodeSettings實例。
BarcodeSettings settings = new BarcodeSettings();
Step 2: 將條碼類型設置為EAN13。
settings.Type = BarCodeType.EAN13;
Step 3: 設置數據進行編碼。
settings.Data = "123456789012";
Step 4: 計算校驗和并將校驗碼添加到條形碼。
settings.UseChecksum = CheckSumMode.ForceEnable;
Step 5: 在底部顯示條形碼文本,并集中對齊文本。
settings.ShowTextOnBottom = true; settings.TextAlignment = StringAlignment.Center;
Step 6: 根據設置生成條形碼圖像并以.png格式保存。
BarCodeGenerator generator = new BarCodeGenerator(settings); Image image = generator.GenerateImage(); image.Save("EAN-13.png", System.Drawing.Imaging.ImageFormat.Png);
輸出:
完整代碼:
BarcodeSettings settings = new BarcodeSettings(); settings.Type = BarCodeType.EAN13; settings.Data = "123456789012"; settings.UseChecksum = CheckSumMode.ForceEnable; settings.ShowTextOnBottom = true; settings.TextAlignment = StringAlignment.Center; BarCodeGenerator generator = new BarCodeGenerator(settings); Image image = generator.GenerateImage(); image.Save("EAN-13.png", System.Drawing.Imaging.ImageFormat.Png);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn