[英]Java Swing barcode creation
I am developing a simple application for printing stickers and I need to print barcodes. 我正在开发一个简单的打印贴纸应用程序,我需要打印条形码。 For some reasons I need to generate barcodes as text not as images.
出于某些原因,我需要生成条形码作为文本而不是图像。 It is all good enough with barcode creation and printing but scanner do not recognize these barcodes.
条形码创建和打印都很好,但扫描仪无法识别这些条形码。
I am using JLabel
component and system barcode font for it ( IDAutomationHC39M, C39HrP24DhTt
) for barcode creation. 我正在使用
JLabel
组件和系统条形码字体( IDAutomationHC39M, C39HrP24DhTt
)来创建条形码。 Scanner tried to recognize it (it automatically switched to constant laser mode) but there is no result. 扫描仪试图识别它(它自动切换到恒定激光模式),但没有结果。
Barcode text example 999-999999-9/9 条形码文本示例999-999999-9 / 9
So, maybe I missed something or did something wrong? 那么,也许我错过了什么或做错了什么? Full explanation or link will be appreciated!
完整的解释或链接将不胜感激!
UPD code example UPD代码示例
barcodeLabel = new JLabel("*"+hwb.getNumber()+"-1/1*");
Font f = new Font("IDAutomationHC39M",java.awt.Font.PLAIN,8);
barcodeLabel.setFont(f);
Please ignore hardcoded "1/1" - it's for test only. 请忽略硬编码的“1/1” - 仅供测试。
UPD printed barcode example UPD打印条码示例
SOME UPDATE 一些更新
It looks strange but seems that problem is in the scanner - I have tried with a laser scanner, the scanner application on my Android phone and got no result. 它看起来很奇怪,但似乎问题出现在扫描仪中 - 我尝试使用激光扫描仪,我的Android手机上的扫描仪应用程序并没有结果。 I called it strange because the scanner successfully worked with code39 barcodes before.
我之所以称之为奇怪,是因为扫描仪之前成功使用了code39条形码。 Now I have tried to scan with zxing-based scanner in my own Android app and it recognized successfully.
现在我尝试在我自己的Android应用程序中使用基于zxing的扫描仪进行扫描,并且它已成功识别。 I will make some experiments with different scanners during next days.
我会在接下来的几天里用不同的扫描仪做一些实验。
FINALLY 最后
I have tried to scan these barcodes on two other scanners (Metrologic and Symbol) and they show perfect results - all barcodes recognized successfully. 我试图在另外两台扫描仪(Metrologic和Symbol)上扫描这些条形码,它们显示出完美的结果 - 所有条形码都能成功识别。 I think all problems was in my cheap scanner - it works great with barcodes printed on laser printer but if print quality is not ideal - it useless.
我认为所有的问题都在我的廉价扫描仪中 - 它适用于激光打印机上印刷的条形码,但如果打印质量不理想 - 它没用。 I'm very sorry that I have started topic because of this stupid device and my own inattention.
我很抱歉,由于这个愚蠢的设备和我自己的疏忽,我已经开始讨论主题。 Anyway thanks for all commentators, topic may be closed.
无论如何,感谢所有评论员,主题可能会被关闭。
I have tried to scan these barcodes on two other scanners (Metrologic and Symbol) and they show perfect results - all barcodes recognized successfully. 我试图在另外两台扫描仪(Metrologic和Symbol)上扫描这些条形码,它们显示出完美的结果 - 所有条形码都能成功识别。 I believe all problems was in my cheap scanner - it works great with barcodes printed on laser printer but if print quality is not ideal - it useless.
我相信所有问题都在我的廉价扫描仪中 - 它适用于激光打印机上打印的条形码,但如果打印质量不理想 - 它没用。 So there was no programm mistakes only hardware limitations.
所以没有程序错误只有硬件限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.