Core barcode encoding/decoding library supporting 17 formats including QR Code, Data Matrix, Aztec, PDF 417, and various 1D barcodes
—
Enumeration of all supported barcode formats in ZXing Core, including 8 1D formats and 5 2D formats. The BarcodeFormat enum is used throughout the API to specify or identify barcode types.
Complete enumeration of all 16 supported barcode formats. Used for specifying desired format when encoding, or returned when decoding to indicate detected format.
/**
* Enumeration of barcode formats supported by ZXing Core.
*/
enum BarcodeFormat {
// 1D Barcode Formats
/** Codabar 1D format */
CODABAR,
/** Code 39 1D format */
CODE_39,
/** Code 93 1D format */
CODE_93,
/** Code 128 1D format */
CODE_128,
/** EAN-8 1D format */
EAN_8,
/** EAN-13 1D format */
EAN_13,
/** ITF (Interleaved 2 of 5) 1D format */
ITF,
/** RSS 14 (GS1 DataBar) */
RSS_14,
/** RSS Expanded (GS1 DataBar Expanded) */
RSS_EXPANDED,
/** UPC-A 1D format */
UPC_A,
/** UPC-E 1D format */
UPC_E,
/** 2 or 5-digit UPC/EAN extension */
UPC_EAN_EXTENSION,
// 2D Barcode Formats
/** Aztec 2D barcode format */
AZTEC,
/** Data Matrix 2D barcode format */
DATA_MATRIX,
/** MaxiCode 2D barcode format */
MAXICODE,
/** PDF417 2D barcode format */
PDF_417,
/** QR Code 2D barcode format */
QR_CODE
}CODABAR
CODE_39
CODE_93
CODE_128
EAN_8
EAN_13
ITF (Interleaved 2 of 5)
RSS_14 (GS1 DataBar)
RSS_EXPANDED (GS1 DataBar Expanded)
UPC_A
UPC_E
UPC_EAN_EXTENSION
AZTEC
DATA_MATRIX
MAXICODE
PDF_417
QR_CODE
Specifying format when encoding:
import com.google.zxing.*;
import com.google.zxing.common.*;
Writer writer = new MultiFormatWriter();
// Encode as QR Code
BitMatrix qrMatrix = writer.encode(
"https://example.com",
BarcodeFormat.QR_CODE,
300,
300
);
// Encode as Code 128
BitMatrix code128Matrix = writer.encode(
"ABC123",
BarcodeFormat.CODE_128,
200,
100
);Limiting decode to specific formats:
import com.google.zxing.*;
import com.google.zxing.common.*;
import java.util.*;
Map<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);
// Only try QR Code and Data Matrix
hints.put(DecodeHintType.POSSIBLE_FORMATS,
Arrays.asList(BarcodeFormat.QR_CODE, BarcodeFormat.DATA_MATRIX));
Reader reader = new MultiFormatReader();
Result result = reader.decode(bitmap, hints);Checking detected format:
import com.google.zxing.*;
import com.google.zxing.common.*;
Result result = reader.decode(bitmap);
BarcodeFormat format = result.getBarcodeFormat();
if (format == BarcodeFormat.QR_CODE) {
System.out.println("Detected QR Code");
} else if (format == BarcodeFormat.EAN_13) {
System.out.println("Detected EAN-13 product barcode");
}For Product Identification:
EAN_13, UPC_AEAN_8, UPC_EEAN_13 with UPC_EAN_EXTENSIONFor General Data Encoding:
QR_CODE (best mobile support)DATA_MATRIXPDF_417QR_CODE (up to 7,089 numeric)For Shipping/Logistics:
CODE_128, RSS_14MAXICODEDATA_MATRIXFor Special Applications:
CODABARITFRSS_EXPANDEDDATA_MATRIX| Format | Type | Max Capacity | Error Correction | Use Case |
|---|---|---|---|---|
| QR_CODE | 2D | 7,089 numeric | 4 levels (7-30%) | URLs, mobile, general |
| DATA_MATRIX | 2D | 3,116 numeric | Reed-Solomon | Small items, electronics |
| PDF_417 | 2D | 1,850 alphanumeric | Reed-Solomon | IDs, transportation |
| AZTEC | 2D | 3,832 numeric | Reed-Solomon | Tickets, no quiet zone |
| CODE_128 | 1D | Variable | Check digit | Shipping, packaging |
| EAN_13 | 1D | 13 digits | Check digit | Retail products |
| UPC_A | 1D | 12 digits | Check digit | North America retail |