C# 条码 128 大小限制。最紧凑的条码字体?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/935814/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Barcode 128 size restrictions. Most compact barcode font?
提问by runxc1 Bret Ferrier
I am generating a barcode label and sending it to the user as a .pdf (this is a web app). The user has already purchased barcode labels that are only 2 inches wide. I want to use an image so that I don't have to install fonts on all of the users machines that will be using the web site. I am able to get the barcodes small enough if I use fonts from IDeautomation.com but I would much rather use an image generated using BarCodeRendereror some other opensource project but I can not get the barcodes small enough as the system has pre-existing ID's of around 20 characters in length. What is the smallest Barcode font (I am trying to use 128 as the IDS are alphanumeric) and how can I resize the generated image in a way to make it fit in the width that I have available?(Other ideas or Libraries that do this are also accepted as answers)
我正在生成一个条形码标签并将其作为 .pdf(这是一个网络应用程序)发送给用户。用户已经购买了只有 2 英寸宽的条码标签。我想使用图像,这样我就不必在将使用该网站的所有用户计算机上安装字体。如果我使用来自 IDeautomation.com 的字体,我能够获得足够小的条形码,但我更愿意使用使用BarCodeRenderer生成的图像或其他一些开源项目,但我无法获得足够小的条形码,因为系统预先存在的 ID 长度约为 20 个字符。最小的条形码字体是什么(我尝试使用 128,因为 IDS 是字母数字)以及如何调整生成的图像的大小以使其适合我可用的宽度?(其他想法或库这样做也被接受作为答案)
回答by RedFilter
I have had good luck using Data Matrixformat as you can have varying amounts of data, and you can size the barcode as you wish.
我使用Data Matrix格式很幸运,因为您可以拥有不同数量的数据,并且您可以根据需要调整条形码的大小。
Here are some links that may help:
以下是一些可能有帮助的链接:
Aspose.BarCode for .NET and Java
用于 .NET 和 Java 的 Aspose.BarCode
回答by jvanderh
What I've done is to take the barcode and make it fit the width that I want by resizing it down. What then happens is that the height is not good enough for most readers, so I copy the image and duplicated it above it, so it now is the width I want and double the height of the generator. That makes it more readable to most common off-the-shelf barcode readers.
我所做的是获取条形码并通过调整其大小使其适合我想要的宽度。然后发生的情况是高度对于大多数读者来说不够好,所以我复制图像并将其复制到它上面,所以它现在是我想要的宽度并且是生成器高度的两倍。这使得它对于最常见的现成条码阅读器更具可读性。
回答by Mark Ransom
If your barcodes only consist of an even number of numeric digits, you can quite easily switch to the Code C variant to get them down to half the size.
如果您的条码只包含偶数个数字,您可以很容易地切换到 Code C 变体,将它们的大小缩小一半。
Generating a small barcode as an image in a PDF is going to be error prone, since you can't optimize to the dot size of the printer. Your barcode widths are going to be off by plus or minus half a dot; the wider your bars are, the less of an issue this will be. I've worked with label printers that are 203 DPI, and they would be nearly impossible to support with a generic image. Fonts are better since they can be hinted to be an exact multiple of dots. I don't know if any of the commercial barcode fonts have the necessary hinting, but I presume at least one of them does.
生成一个小的条形码作为 PDF 中的图像很容易出错,因为您无法优化打印机的点大小。您的条码宽度将偏离正负半个点;你的酒吧越宽,这个问题就越少。我使用过 203 DPI 的标签打印机,它们几乎不可能支持通用图像。字体更好,因为可以暗示它们是点的精确倍数。我不知道是否有任何商业条码字体有必要的提示,但我认为其中至少有一个。
回答by Jas Panesar
IDautomation has several products.
IDautomation 有几个产品。
Specifically they have one for Crystal reports with a Code 128 checksum calculator. It bypasses the need for a font and generates the font right in the report, which can go straight to PDF. The smallest size I have been able to use this feature is at about 12 point font. Specifically they have broken down the Code 128 font spec to allow you the smallest barcodes possible. This does not render as a font, or an image as far as I recall.
具体来说,他们有一个带有 Code 128 校验和计算器的 Crystal 报告。它绕过了对字体的需求,并在报告中直接生成字体,可以直接转为 PDF。我能够使用此功能的最小尺寸约为 12 磅字体。具体来说,他们已经分解了 Code 128 字体规范,以允许您使用尽可能小的条形码。据我回忆,这不会呈现为字体或图像。
Alternatively I recall them having a product that will render a font as an image.
或者,我记得他们有一款产品可以将字体呈现为图像。
Another product that might be useful is Barbeque. Maybe you can find something along that line.
另一种可能有用的产品是Barbeque。也许你可以在这条线上找到一些东西。
The other factors that weigh in when trying to print and read small barcodes are:
在尝试打印和读取小条码时,其他重要的因素是:
How long is the value that you are encoding in the barcode. 20 Characters is a lot.. Is there any way you can concatenate it, or shrink it somehow? Tricks I have used in the past include using a hashed value (or record number) that would link to all the values I needed. The shorter you can get your barcode, the smaller you can make it and still have it super clear.
Will the barcode get longer over time? If so, you might need a wider label, or consider a different format. I am starting to like a few of the 2D barcodes a lot.
Label material. I have seen issues with using colored or overly shiny labels instead of white, matte ones making it much harder to read.
The barcode readers can make a big difference. Having a laser based reader instead of an optical based one will give you greater resolution in reading barcodes. This means you can read them from further away, or read smaller ones. Symbol has some great $150 laser based barcode scanners.
您在条形码中编码的值有多长。20个字符很多..有什么办法可以连接它,或者以某种方式缩小它?我过去使用的技巧包括使用一个散列值(或记录号),它可以链接到我需要的所有值。你的条形码越短,你就能让它越小,而且仍然非常清晰。
条形码会随着时间变长吗?如果是这样,您可能需要更宽的标签,或考虑不同的格式。我开始非常喜欢一些二维条码。
标签材料。我已经看到使用彩色或过于闪亮的标签而不是白色、哑光标签的问题,这使得阅读变得更加困难。
条形码阅读器可以产生很大的不同。使用基于激光的阅读器而不是基于光学的阅读器将使您在读取条码时具有更高的分辨率。这意味着您可以从更远的地方阅读它们,或者阅读较小的。Symbol 有一些很棒的 150 美元基于激光的条码扫描仪。
The bar code printing and reading systems I've worked on have done in the range of a few million prints and reads with barcodes of small to medium sizes, so I hope some of the suffering and learning I've had above helps!
我工作过的条码打印和读取系统已经完成了几百万次打印和读取中小型条码的工作,所以我希望我上面的一些痛苦和学习能有所帮助!