java ean13 条形码_【教程】Spire.Barcode 教程:如何在C#中创建EAN-13条码
基于UPC-A標準的EAN-13在世界范圍內用于標記零售商品。 13位EAN-13號碼由四部分組成:
國家代碼 - 2或3位數字
制造商代碼 - 5至7位數字
產品代碼 - 3至5位數字
檢查數字 - 最后一位數字
代碼演示:
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);
標簽:條形碼Barcode條形碼生成
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,尊重他人勞動成果
0
好文不易,鼓勵一下吧!
總結
以上是生活随笔為你收集整理的java ean13 条形码_【教程】Spire.Barcode 教程:如何在C#中创建EAN-13条码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 通道 双向原理_Java-NI
- 下一篇: java项目中多个定时器_在java项目