iTextSharp BarcodePDF417,如何处理文本中编码的 2000 个或更多字符的条码

iTextSharp BarcodePDF417, how to handle barcode with 2000 characters or more encoded in text

我正在尝试在条形码中编码超过 2000 个字符。

Random random = new Random();
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var text = new string(Enumerable.Repeat(chars, 2000)
    .Select(s => s[random.Next(s.Length)]).ToArray());
var barcode = new BarcodePDF417();
barcode.SetText(text);
barcode.GetImage();

尝试 GetImage() 时收到错误。

System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values. (Parameter 'The text is too big.')'

我知道有一个宏版本,您可以在其中 link 数据。但是,生成的条形码不再统一。我只想要 1 个可扫描的条形码。这可以使用 ITextSharp 实现吗?

barcode.MacroFileId = "0"
barcode.MacroSegmentId = someIndexinLoop;
barcode.MacroSegmentCount = totalCount;

不可以,单个 PDF417 投诉条码内是不可能的。

您可以按照建议使用多个条形码或 link 来获取更多数据,或者如果您可以控制将读取条形码的应用程序,那么您可以使用奇特的技巧,例如条形码中的短代码可以由执行扫描的应用程序扩展为一些预设字符串。

ISO 规范中显示的 PDF417 规范,或 here 确实有限制:

PDF417 is capable of encoding more than 1100 bytes, 1800 text characters or 2710 digits. Large data files can be encoded into a series of linked PDF417 symbols using a standard methodology referred to as Macro PDF417.

还有一些很棒的信息here:

It is recommended to limit the amount of data in each 2D barcode symbol to 800 characters or less, using 20 columns or less. Although the specification states that “up to 1100 bytes or 1800 ASCII characters can be encoded in a PDF417 symbol,” it is not usually achievable. The amount of data that can be encoded will vary depending upon the type of data, the compaction type, the error correction level chosen and the limitation of the scanner being used. For example, in text compaction mode, the amount of compaction varies due to mode switching between different types of characters, such as between numbers, upper case, lower case and punctuation. In addition, many PDF417 CCD scanners do not reliably read more than 800 to 850 characters and some scanners have limits of only 300 characters.