【发布时间】:2010-06-23 05:10:41
【问题描述】:
哪个是Java中更好的条形码生成库。我看到 JBar 和 Barbecue 有两个选择。 非常感谢任何现实生活中的使用。
【问题讨论】:
哪个是Java中更好的条形码生成库。我看到 JBar 和 Barbecue 有两个选择。 非常感谢任何现实生活中的使用。
【问题讨论】:
我试过Barcode4J。不错的一个
【讨论】:
我认为 Barbecue 是一个开源且易于使用的 Java 库,因此它是最好的。此外,ZXing(发音为“斑马线”)是一个用 Java 实现的开源、多格式 1D/2D 条形码图像处理库。参见此链接http://code.google.com/p/zxing/
【讨论】:
我更喜欢烤肉,比较稳定简单
[此处的示例(http://bethecoder.com/applications/tutorials/barcodes/barbecue/barcode-size.html)
public class BarCodeSizeTest {
public static void main (String [] args) throws Exception {
//Get 128B Barcode instance from the Factory
Barcode barcode = BarcodeFactory.createCode128B("be the coder");
barcode.setBarHeight(60);
barcode.setBarWidth(2);
File imgFile = new File("testsize.png");
//Write the bar code to PNG file
BarcodeImageHandler.savePNG(barcode, imgFile);
}
}
【讨论】:
我用过Barbecue。
简单的例子真的很琐碎:
BufferedImage image = BarcodeImageHandler.getImage(BarcodeFactory.createCode128("BARCODE"));
之后,您可以通过 ByteArrayOutputStream 将 image 转换为 byte[]。
【讨论】:
我用过“zxing”
有以下依赖,
https://mvnrepository.com/artifact/com.google.zxing/core https://mvnrepository.com/artifact/com.google.zxing/javase
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(inputText, BarcodeFormat.QR_CODE, width, height);
Path path = FileSystems.getDefault().getPath(filePath);
MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path);
你可以转换成图片使用,
Image image = MatrixToImageWriter.toBufferedImage(bitMatrix);
【讨论】: