Java中的条码图像生成器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1700597/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 21:42:59  来源:igfitidea点击:

BarCode Image Generator in Java

javageneratorbarcode

提问by om.

How can I create a barcode image in Java? I need something that will allow me to enter a number and produce the corresponding barcode image. Is there a free library available for this type of task?

如何在 Java 中创建条形码图像?我需要一些可以让我输入数字并生成相应条形码图像的东西。是否有可用于此类任务的免费库?

采纳答案by Chris Dail

iTextis a great Java PDF library. They also have an API for creating barcodes. You don't need to be creating a PDF to use it.

iText是一个很棒的 Java PDF 库。他们还有一个用于创建条形码的 API。您无需创建 PDF 即可使用它。

This page has the details on creating barcodes. Here is an example from that site:

此页面包含有关创建条形码的详细信息。这是该站点的示例:

BarcodeEAN codeEAN = new BarcodeEAN();
codeEAN.setCodeType(codeEAN.EAN13);
codeEAN.setCode("9780201615883");
Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);

The biggest thing you will need to determine is what type of barcode you need. There are many different barcode formats and iText does support a lot of them. You will need to know what format you need before you can determine if this API will work for you.

您需要确定的最重要的事情是您需要什么类型的条形码。有许多不同的条码格式,iText 确实支持其中的很多。在确定此 API 是否适合您之前,您需要知道您需要什么格式。

回答by True Soft

There is a free library called barcode4j

有一个名为barcode4j的免费库

回答by Arto Uusikangas

There is also this free API that you can use to make free barcodes in java.

还有这个免费的 API,您可以使用它在 Java 中制作免费的条形码。

Barbecue

烧烤

回答by bguiz

I use barbeque, it's great, and supports a very wide range of different barcode formats.
See if you like its API.

我使用 barbeque,它很棒,并且支持非常广泛的不同条码格式。
看看你是否喜欢 它的 API

Sample API:

示例 API:

public static Barcode createCode128(java.lang.String data)
                             throws BarcodeException

Creates a Code 128 barcode that dynamically switches between character sets to give the smallest possible encoding. This will encode all numeric characters, upper and lower case alpha characters and control characters from the standard ASCII character set. The size of the barcode created will be the smallest possible for the given data, and use of this "optimal" encoding will generally give smaller barcodes than any of the other 3 "vanilla" encodings.

创建可在字符集之间动态切换的 Code 128 条形码,以提供尽可能小的编码。这将对标准 ASCII 字符集中的所有数字字符、大小写字母字符和控制字符进行编码。对于给定的数据,创建的条形码的大小将是最小的,并且使用这种“最佳”编码通常会产生比其他 3 种“普通”编码中的任何一种都更小的条形码。

回答by Vineet Manohar

ZXingis a free open source Java library to read and generate barcode images. You need to get the source code and build the jars yourself. Here's a simple tutorialthat I wrote for building with ZXing jars and writing your first program with ZXing.

ZXing是一个免费的开源 Java 库,用于读取和生成条码图像。您需要获取源代码并自己构建 jar。这是我为使用 ZXing jar 构建并使用 ZXing 编写您的第一个程序而编写的简单教程

[http://www.vineetmanohar.com/2010/09/java-barcode-api/]

[ http://www.vineetmanohar.com/2010/09/java-barcode-api/]