简体   繁体   English

如何在 JAVA 中使用 itext API 创建固定大小(高度和宽度)的二维条码?

[英]How to create fixed size(height and width) 2d barcode using itext API in JAVA?

I am trying to create a fixed size(height and width) 2d barcode in java using itext api, but barcode size is changing based on length of code we set to barcode object.我正在尝试使用 itext api 在 java 中创建一个固定大小(高度和宽度)的二维条码,但条码大小正在根据我们设置为条码对象的代码长度而变化。 More the length of code we set, longer the barcode is generated.我们设置的代码长度越长,生成的条形码就越长。 please help.请帮忙。

 BarcodePDF417 barcode = new BarcodePDF417();
 barcode.setCode("BarcodePDF417 barcode");

Here is A Blank PDF417 BarCode with NO Data这是一个没有数据的空白 PDF417 条码

在此处输入图片说明

Here is the minimal test data just a small one line phrase这是最小的测试数据只是一个小的单行短语

在此处输入图片说明

Here is a longer single line of text "The quick brown fox jumps over the lazy dog"这是一行较长的文本“快速的棕色狐狸跳过懒惰的狗”

在此处输入图片说明

And "PDF417 is a stacked linear barcode symbol format used in a variety of applications, primarily transport, identification cards, and inventory management." “PDF417 是一种堆叠式线性条码符号格式,用于各种应用,主要是运输、身份证和库存管理。” produces产生在此处输入图片说明

Clearly as you add more content the size needs to increase in steps.显然,随着您添加更多内容,大小需要逐步增加。

See https://en.wikipedia.org/wiki/PDF417 where it explains how the barcode needs to be much longer for PDF417 characters than say a QR type barcode and can thus never be "fixed" height for a fixed width unless code length is always the same.请参阅https://en.wikipedia.org/wiki/PDF417 ,其中解释了 PDF417 字符的条码如何比 QR 类型条码长得多,因此除非代码长度,否则永远不能为固定宽度“固定”高度总是一样的。 Also consider distance to scanner also dictates the minimum working area where for a QR code the size ratio is recommended as 1/10 scanner distance but I dont know how that is guaged for PDF417 as it is usually scanned in contact thus the key is the minimum size of x (1) and y (usually 3) needed to achieve a reliable result.还要考虑到扫描仪的距离也决定了最小工作区域,对于 QR 码,建议尺寸比为 1/10 扫描仪距离,但我不知道 PDF417 是如何测量的,因为它通常是接触式扫描的,因此关键是最小的获得可靠结果所需的 x (1) 和 y (通常为 3) 的大小。

For comparisons against your own output you can use an online creator such as https://bcgen.com/pdf417-barcode-creator.html为了与您自己的输出进行比较,您可以使用在线创建器,例如https://bcgen.com/pdf417-barcode-creator.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何设置iText条码宽度? - How to set iText barcode width? 如何使用 Java 中的 Scanner 创建具有指定行大小的二维数组而不指定列大小? - How to create 2D array with specified row size without specifying columns size using Scanner in Java? 如何在高度或宽度大小的一维数组中呈现二维数组 - how to present a 2d array in an 1d array with a size of height or width 如何在 iText JAVA 中给出列宽的固定百分比值 - How to give fixed percentage value of column width in iText JAVA 如何使用java在给定新高度和宽度的情况下更改图像大小? - How to change the size of image with given new height and width using java? 查找未知尺寸的二维数组的最大高度和宽度(Java) - Finding Maximum Height and Width for 2D Array of Unknown Dimensions (Java) 如何在 Java 中使用二维数组创建表? - How do I create a table using 2D array in Java? 如何创建包含2d Arraylist的2d数组? (JAVA) - How to create 2d Array containing 2d Arraylist? (JAVA) 如何使用java设置生成的pdf417条形码的宽度 - How to set width of generated pdf417 barcode using java 使用 iText 的页脚中的动态高度大小 - Dynamic Height size in footer using iText
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM