CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-google-zxing--core

Core barcode encoding/decoding library supporting 17 formats including QR Code, Data Matrix, Aztec, PDF 417, and various 1D barcodes

Pending
Overview
Eval results
Files

barcode-formats.mddocs/reference/

Barcode Formats

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.

Capabilities

BarcodeFormat Enum

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
}

Format Descriptions

1D Barcode Formats

CODABAR

  • Variable-length numeric format with start/stop characters
  • Commonly used in libraries, blood banks, and package tracking
  • Supports digits 0-9 and characters - $ : / . +

CODE_39

  • Variable-length alphanumeric format
  • Widely used in non-retail applications
  • Supports uppercase letters, digits, and limited special characters
  • Optional check digit

CODE_93

  • Compact alphanumeric format
  • More compact than Code 39
  • Built-in error checking
  • Supports full ASCII character set

CODE_128

  • High-density variable-length format
  • Supports full ASCII character set
  • Widely used in shipping and packaging
  • Excellent data efficiency

EAN_8

  • Fixed 8-digit product barcode
  • International Article Number (shortened)
  • Used for small product packages
  • Includes check digit

EAN_13

  • Fixed 13-digit product barcode
  • International Article Number (standard)
  • Widely used for retail products worldwide
  • Includes check digit

ITF (Interleaved 2 of 5)

  • Numeric-only format
  • Even number of digits required
  • Used in warehouse and distribution
  • High density for numeric data

RSS_14 (GS1 DataBar)

  • 14-digit GS1 standard format
  • More compact than traditional UPC/EAN
  • Can encode additional data
  • Used for coupons, small items

RSS_EXPANDED (GS1 DataBar Expanded)

  • Variable-length GS1 format
  • Can encode product and additional information
  • Supports expiration dates, weight, batch numbers
  • Used in grocery and healthcare

UPC_A

  • Fixed 12-digit product barcode
  • Universal Product Code (standard)
  • Primary barcode format for retail in North America
  • Includes check digit

UPC_E

  • Compressed 6-digit version of UPC-A
  • Zero-suppressed format
  • Used for small product packages
  • Expands to full UPC-A

UPC_EAN_EXTENSION

  • 2 or 5-digit extension to UPC/EAN
  • Used for supplemental information
  • Common on magazines and books for pricing

2D Barcode Formats

AZTEC

  • Square 2D matrix symbology
  • Variable capacity (up to 3,832 numeric characters)
  • Built-in error correction
  • No quiet zone required
  • Compact and full-range variants

DATA_MATRIX

  • Square or rectangular 2D matrix symbology
  • Variable capacity (up to 3,116 numeric characters)
  • Reed-Solomon error correction
  • Excellent for small items and direct part marking
  • Used in electronics, healthcare, logistics

MAXICODE

  • Fixed-size 2D matrix (1 inch square)
  • Designed for high-speed sorting
  • Used primarily by shipping companies (UPS)
  • Contains finder pattern in center
  • Capacity: ~93 characters

PDF_417

  • Stacked linear 2D symbology
  • Variable capacity (up to 1,850 alphanumeric characters)
  • Reed-Solomon error correction
  • Multiple compaction modes (text, byte, numeric)
  • Used in identification documents, transportation, inventory

QR_CODE

  • Square 2D matrix symbology
  • Variable capacity (up to 7,089 numeric characters)
  • Reed-Solomon error correction (4 levels)
  • Fast readability with finder patterns
  • Widely used for mobile applications, URLs, payments
  • Versions 1-40 with increasing capacity

Usage Examples

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");
}

Format Selection Guidelines

For Product Identification:

  • Retail products: EAN_13, UPC_A
  • Small products: EAN_8, UPC_E
  • Books/magazines: EAN_13 with UPC_EAN_EXTENSION

For General Data Encoding:

  • URLs/mobile: QR_CODE (best mobile support)
  • Small data on small items: DATA_MATRIX
  • Documents/IDs: PDF_417
  • Large data capacity: QR_CODE (up to 7,089 numeric)

For Shipping/Logistics:

  • Packages: CODE_128, RSS_14
  • High-speed sorting: MAXICODE
  • Small items: DATA_MATRIX

For Special Applications:

  • Libraries/blood banks: CODABAR
  • Warehouse: ITF
  • Grocery/healthcare: RSS_EXPANDED
  • Direct part marking: DATA_MATRIX

Format Capabilities Comparison

FormatTypeMax CapacityError CorrectionUse Case
QR_CODE2D7,089 numeric4 levels (7-30%)URLs, mobile, general
DATA_MATRIX2D3,116 numericReed-SolomonSmall items, electronics
PDF_4172D1,850 alphanumericReed-SolomonIDs, transportation
AZTEC2D3,832 numericReed-SolomonTickets, no quiet zone
CODE_1281DVariableCheck digitShipping, packaging
EAN_131D13 digitsCheck digitRetail products
UPC_A1D12 digitsCheck digitNorth America retail

Install with Tessl CLI

npx tessl i tessl/maven-com-google-zxing--core

docs

index.md

tile.json