Yes, ZXing can generate GS1-128 barcodes using Java. The GS1-128 symbology is also known as EAN-128 or UCC-128 and is a standardized format that is widely used for product labeling in supply chain applications. To generate GS1-128 barcodes using Java, you can use the GS1Code128Writer class provided by the ZXing library. Here is an example code snippet that generates a GS1-128 barcode:
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.oned.Code128Writer;
import com.google.zxing.oned.EAN13Writer;
import com.google.zxing.oned.UPCAWriter;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.util.HashMap;
import java.util.Map;
public class GenerateBarcode {
public static void main(String[] args) {
String gs1Data = "(01)12345678901234(10)ABCDEFG";
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
GS1Code128Writer writer = new GS1Code128Writer();
try {
BitMatrix bitMatrix = writer.encode(gs1Data, BarcodeFormat.CODE_128, 400, 200, hints);
// TODO: Render the BitMatrix as an image or print the barcode
} catch (WriterException e) {
e.printStackTrace();
}
}
}
In this example, the gs1Data
string represents the GS1 data to be encoded in the barcode, and the hints
map provides additional encoding options such as the character set and error correction level. The GS1Code128Writer
class is used to encode the GS1 data as a Code 128 barcode, which is the basis for the GS1-128 symbology. Finally, the resulting BitMatrix
can be rendered as an image or printed to generate the actual barcode.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-08-16 11:00:00 +0000
Seen: 10 times
Last updated: Mar 31 '22
How can the rejection of the class text_plain from JavaMail API due to a VerifyError be confirmed?
What is the process for generating a dynamic subdomain/URL using vue.js?
How can the style of the loader be modified while the form submission is being processed?
I'm attempting to develop a Javascript-based comments section for my website.
What are some feasible methods to enable MIDI file playback on a web browser?
How can I resolve the issue of being unable to use Fetch to POST an array of Selected Checkboxes?
What is the method to hide the scroll button when reaching the bottom?
What is the process of using a custom nunjucks filter to filter collections in an eleventy template?