C#:生成代码128条形码(条/空格的宽度) [英] C# : Generating Code 128 Barcode (width of bars/spaces)

查看:137
本文介绍了C#:生成代码128条形码(条/空格的宽度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我继承了这段代码,或者应该说,有人开发了此代码并继续前进,现在我们遇到了问题,我正在研究它...

So I inherited this code, or should I say, someone developed this and moved on and now we are having a problem with it and I'm looking into it...

我们正在生成c128条码,通过对其进行认证后,他们注意到了一个我看不出的问题.条/间距的宽度为10.5密耳,可接受范围为15-21密耳(1密耳= .001英寸).

We are generating c128 barcodes and upon having them certified they noticed an issue that I can't see to figure out. The width of a bars/spaces is 10.5 mils and they acceptable range is 15-21 mils (1 mil = .001 inch).

渲染代码基于以下库: http://www.codeproject.com/KB/GDI-plus/GenCode128.aspx ,但已对其进行了一些修改...

The rendering code is based off this library: http://www.codeproject.com/KB/GDI-plus/GenCode128.aspx but has been modified some...

正在生成的条形码均为字母数字,无特殊字符.我认为bar +空格的宽度取决于所编码的字符.

The barcodes being generated are all alpha-numeric, no special characters. I thought the width of the bar + space was dependent on the character being encoded.

以下是正在使用的设置:

Here are the settings being used:

settings.Font = new Font ( FontFamily.GenericSansSerif, 12 );
settings.TopMargin = 10
settings.BottomMargin = 10
settings.LeftMargin = 10
settings.RightMargin = 10
settings.BarCodeHeight = 80
settings.DrawText = true
settings.BarCodeToTextGapHeight = 10
settings.InterCharacterGap = 2

如果我在猜测,我认为是因为条形的宽度是基于条形码的高度,而不是条形码的高度是基于文本和条形码的长度.但是我对规范不是很熟悉(即使在阅读它之后也是如此),而且我充其量只是C#的新手...

If I was guessing, I think it's because the width of the bars is being based on the height of the barcode instead of the height of the barcode being based on the length of the text and barcode. But I'm not too familiar with the spec (even after reviewing it), and I'm a novice C# programmer at best...

推荐答案

这不是直接的答案,但我强烈建议使用经过良好测试的库来生成条形码...正确设置条形码并不容易,因为有一些陷阱...那里有大量的图书馆,有一些商业的,有一些免费的...

This isn't a direct answer BUT I would strongly recommend to use a well-tested library for generating barcodes... getting barcodes right isn't easy since there are some pitfalls... there are tons of libraries out there some commercial, some free...

2个用于.NET的免费条形码库:
http://barcoderender.codeplex.com/
http://www.codeproject.com/KB/graphics/BarcodeLibrary.aspx

2 free barcode libraries for .NET:
http://barcoderender.codeplex.com/
http://www.codeproject.com/KB/graphics/BarcodeLibrary.aspx

这篇关于C#:生成代码128条形码(条/空格的宽度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆