SkillAgentSearch skills...

OkapiBarcode

Open-source barcode encoding program written in Java

Install / Use

/learn @woo-j/OkapiBarcode
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Okapi Barcode

License Maven Central Reproducible Builds Code Coverage

Okapi Barcode is an open-source barcode generator written entirely in Java, supporting over 50 encoding standards, including all ISO standards. Okapi Barcode is based on Zint, an open-source barcode encoding library developed in C, and builds on the years of work that have been invested in that project.

Supported Symbologies

Library Usage (Java)

Okapi Barcode JARs are available for download from Maven Central.

To generate barcode images in your own code using the Okapi Barcode library, use one of the symbology classes linked above:

  1. instantiate the barcode class,
  2. customize any relevant settings,
  3. invoke setContent(String), and then
  4. pass the barcode instance to one of the available renderers (Java 2D, PostScript, SVG)
Code128 barcode = new Code128();
barcode.setFontName("Monospaced");
barcode.setFontSize(16);
barcode.setModuleWidth(2);
barcode.setBarHeight(50);
barcode.setHumanReadableLocation(HumanReadableLocation.BOTTOM);
barcode.setContent("123456789");

int width = barcode.getWidth();
int height = barcode.getHeight();

BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2d = image.createGraphics();
Java2DRenderer renderer = new Java2DRenderer(g2d, 1, Color.WHITE, Color.BLACK);
renderer.render(barcode);

ImageIO.write(image, "png", new File("code128.png"));

Library Usage (Android)

If you'd like to use Okapi Barcode on the Android platform, the easiest approach is to use the SVG renderer to render your barcode to SVG, and then use a library like AndroidSVG to draw the resultant SVG image on an Android Bitmap or Canvas:

Code128 barcode = new Code128();
barcode.setFontName("Monospaced");
barcode.setFontSize(16);
barcode.setModuleWidth(2);
barcode.setBarHeight(50);
barcode.setHumanReadableLocation(HumanReadableLocation.BOTTOM);
barcode.setContent("123456789");

ByteArrayOutputStream stream = new ByteArrayOutputStream();
SvgRenderer renderer = new SvgRenderer(stream, 1, Color.WHITE, Color.BLACK, true);
renderer.render(barcode);

String content = new String(stream.toByteArray(), StandardCharsets.UTF_8);
SVG svg = SVG.getFromString(content);
svg.renderToCanvas(canvas);

GUI Usage

To use the Swing GUI, just run the OkapiUI class. The GUI allows you to explore the supported barcode symbologies and test them with different configurations and data.

Okapi GUI Screenshot

Building

gradlew check: Compiles and runs all quality checks, including the unit tests.
gradlew fuzz: Runs barcode encoding fuzz tests using Jazzer.
gradlew jar: Builds the JAR file.
gradlew publish: Deploys to Maven Central (requires a modified gradle.properties file).

Recent Releases

Okapi Barcode 0.5.5

  • Aztec Code: allow more fine-grained control over error correction percentage
  • Aztec Code: deprecate setPreferredEccLevel (use setPreferredEccPercentage instead)

Okapi Barcode 0.5.4

  • NVE-18: do not ignore user-provided bar height

Okapi Barcode 0.5.3

  • Performance improvements for 2D matrix barcodes (Data Matrix, QR Code, etc)
  • QR Code: fix bugs in mask evaluation

Okapi Barcode 0.5.2

  • QR Code: add support for structured append

Okapi Barcode 0.5.1

  • Japanese Postal Code: fix bug encoding some letters
  • Japanese Postal Code: throw exception if input data is too long
  • PDF417, MicroPDF417: improve error messages
  • JavaDoc improvements

Okapi Barcode 0.5.0

  • Update GS1 AI validations per 2025 specifications
  • Include license in JAR file

Okapi Barcode 0.4.9

  • Codablock F: allow user to customize row height
  • Codablock F: allow user to customize module width
  • Codablock F: improve check digit calculation
  • Codablock F: fix encodation bugs in various corner cases
  • Add optional rotation parameter to all renderers

Okapi Barcode 0.4.8

  • MaxiCode: improve handling of partial and malformed postal codes (modes 2 and 3)
  • Code 11: allow empty content, if user requests it
  • Micro QR Code: allow empty content, if user requests it
  • Micro QR Code: fix last data character ignored during encoding in some scenarios

Okapi Barcode 0.4.7

  • Update build toolchain from Java 17 to Java 21 (minimum target runtime remains Java 8)
  • SVG and EPS output: round up canvas dimensions when using decimal magnification factor
  • MaxiCode: reduce memory use during encoding
  • QR Code: reduce encode time by about 25%

Okapi Barcode 0.4.6

  • QR Code: allow FNC1 escape sequences in user-provided content
  • Code 39 Extended: allow empty content, if user requests it
  • QR Code: allow empty content, if user requests it
  • UPC/EAN: allow empty content, if user requests it
  • Telepen: allow empty content, if user requests it

Okapi Barcode 0.4.5

  • Code 128: allow user to restrict the code sets used to encode data
  • First [reproducible build](https://github.com/jvm-repo-rebuild/reproducible
View on GitHub
GitHub Stars391
CategoryDevelopment
Updated24d ago
Forks103

Languages

Java

Security Score

95/100

Audited on Mar 7, 2026

No findings