条形码(代码128)字体不能扫描有问题
问题说明
使用Font()
可以轻松生成3 of 9条形码
Font f = new Font("Free 3 of 9", 80);
this.Font = f;
Label l = new Label();
l.Text = "*STACKOVERFLOW*";
l.Size = new System.Drawing.Size(800, 600);
this.Controls.Add(l);
this.Size = new Size(800, 600);
它在工作。我看到条形码,我就能扫描它了。现在我想使用其他东西,如Code 128,因此我需要安装字体(完成),然后只需更改
Font f = new Font("Free 3 of 9", 80);
至Font f = new Font("Code 128", 80);
在那之后,我看到我的窗户上有一个条形码。问题是我不能扫描它。我认为这是因为我没有为条形码使用正确的开始和停止标记。正如我所理解的那样,总得有一个开始/停止字符或其他什么。对于9个代码中的3个,代码128的*我不确定。在Wiki上有开始代码A,所以我尝试了 Font f = new Font("<Start Code A>test<Stop>", 80);
、Font f = new Font("<Start Code A>test<Stop Code A>", 80);
等等...我无法扫描输出。因为扫描仪找不到开始和结束字符。有什么主意吗?谢谢您
正确答案
代码128完全可以用字体表示。这比9中的3更棘手,因为您必须在末尾包括一个校验和字符,该字符需要根据条形码的内容动态计算。还有3个不同的版本,每个版本都有不同的起始字符。
换句话说,条形码的布局需要如下:
[start char][barcode][checksum][stop char]
code128的好处是它比9中的3更简洁。
This page帮助我计算出了计算校验和的算法。
该算法的概述如下:
-
条形码的每个字符都分配了一个特定值 根据角色是什么以及它在 条形码。
-
以上%1)中的所有值相加。
-
获取上面2)中总和的模数值103。
-
在大多数情况下,校验和字符将是ASCII代码:(模数值 加32),如上面3)所确定。
/li>
有一些细微的差别,我最终需要在所有东西的Java脚本中创建这个算法(没有问题)。为了供我将来参考,并显示一些细微差别,它看起来是这样的:
/*
* This is the variable part of my barcode, I append this to a
* static prefix later, but I need to perform logic to compute the
* checksum for this variable. There is logic earlier that enforces
* this variable as a 9 character string containing only digits.
*/
var formIncrement = // a 9 char "digit" string variable
/*
* Dynamically compute the total checksum value (before modulus)
* for the variable part of my barcode, I will need to get a modulus
* from this total when I am done. If you need a variable number of
* characters in your barcodes or if they are not all digits
* obviously something different would have to be done here.
*/
var incrementCS = ((parseInt(formIncrement.charAt(0)) 16) * 7)
((parseInt(formIncrement.charAt(1)) 16) * 8)
((parseInt(formIncrement.charAt(2)) 16) * 9)
((parseInt(formIncrement.charAt(3)) 16) * 10)
((parseInt(formIncrement.charAt(4)) 16) * 11)
((parseInt(formIncrement.charAt(5)) 16) * 12)
((parseInt(formIncrement.charAt(6)) 16) * 13)
((parseInt(formIncrement.charAt(7)) 16) * 14)
((parseInt(formIncrement.charAt(8)) 16) * 15);
/*
* 452 is the total checksum for my barcodes static prefix (600001),
* so it doesn't need to be computed dynamically, I just add it to
* the variable checksum total determined above and then get the
* modulus of that sum:
*/
var checksum = (452 incrementCS) % 103
var barcode = "š600001" formIncrement
/*
* The 0 and the 95 - 102 cases had to be defined explicitly because
* their checksum figures do not line up with the javascript char
* codes for some reason (see the code 128 definition table in the
* linked page) otherwise we simply need to get the charCode of the
* checksum 32. I also tack on the stop char here.
*/
switch (checksum) {
case 0 :
barcode = "€œ";
break;
case 95 :
barcode = "‘œ";
break;
case 96 :
barcode = "’œ";
break;
case 97 :
barcode = ""œ";
break;
case 98 :
barcode = ""œ";
break;
case 99 :
barcode = "•œ";
break;
case 100 :
barcode = "–œ";
break;
case 101 :
barcode = "—œ";
break;
case 102 :
barcode = "˜œ";
break;
default :
barcode = String.fromCharCode(checksum 32) "œ";
}
return barcode;
您可能注意到,我的示例(š,œ)中的开始字符和结束字符似乎与链接页面上显示的字符不匹配。如果我没记错的话,我想是因为我有一些非标准的代码128字体,而这些字符被翻译成正确的字符。
编辑
我重新查看了我的文档。看起来我的字体是从right here得到的。使用该字体并使用上述算法,我刚刚为test
制作了一个代码128b条形码,结果显示为štestwœ
,扫描效果良好。您的校验和算法似乎工作得很好,因为我们都有w
,但如果您得到:ÌtestwÎ
,则您的开始和停止代码似乎已关闭。
我特意寻找我正在使用的相同条形码字体,因为我有一种感觉,不同品牌的code128字体可能实现不同的字符来表示开始和结束条形码。
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanfeijg
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
检查邮件是否发送成功
it1352 07-25 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22