Skip to content

metanorma/barcode4j

Repository files navigation

Barcode4J (Metanorma fork)

Build Status Maven Central License

General

Barcode4J is a flexible generator for barcodes written in Java. This is a modernized fork maintained by Ribose for the Metanorma project.

About this fork

This fork modernizes the original Barcode4J library with:

  • Modern Java support: Updated to Java 8+ with testing on JDK 8, 11, 17, and 21

  • Maven-first: Fully Maven-based build system with modern plugins

  • CI/CD pipeline: Comprehensive GitHub Actions workflow testing on Ubuntu, Windows, and macOS

  • Updated dependencies: All dependencies updated to latest stable versions

  • Code quality: Integrated Checkstyle, SpotBugs, and OWASP dependency checking

  • Security: Regular vulnerability scanning and dependency updates

  • UTF-8 encoding: Modern character encoding throughout

Features

Barcode4J supports generation of the following barcode formats:

1D barcodes

  • Code 39 (3 of 9)

  • Code 128 (including GS1-128/EAN-128)

  • Codabar (2 of 7)

  • Interleaved 2 of 5 (ITF-14)

  • UPC-A and UPC-E

  • EAN-13 and EAN-8

  • POSTNET and Royal Mail CBC

  • USPS Intelligent Mail

2D barcodes

  • Data Matrix

  • PDF417

  • QR Code

Output formats

  • SVG (Scalable Vector Graphics)

  • EPS (Encapsulated PostScript)

  • Bitmap formats (PNG, JPEG, GIF, TIFF, BMP)

  • Java2D (for direct rendering)

Installation

Maven

Add the following dependency to your pom.xml:

<dependency>
    <groupId>org.metanorma</groupId>
    <artifactId>barcode4j</artifactId>
    <version>2.4.0-SNAPSHOT</version>
</dependency>

Gradle

Add the following to your build.gradle:

implementation 'org.metanorma:barcode4j:2.4.0-SNAPSHOT'

Usage

Basic example

import org.krysalis.barcode4j.impl.code128.Code128Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;

// Create barcode bean
Code128Bean bean = new Code128Bean();
bean.setModuleWidth(0.21);
bean.setBarHeight(10.0);

// Generate barcode
BitmapCanvasProvider canvas = new BitmapCanvasProvider(
    300, BufferedImage.TYPE_BYTE_BINARY, false, 0);
bean.generateBarcode(canvas, "Hello World");
canvas.finish();

// Get the generated image
BufferedImage image = canvas.getBufferedImage();

Command line usage

java -jar barcode4j-2.4.0-SNAPSHOT.jar -f svg -o barcode.svg "Hello World"

Building from source

Prerequisites

You will need:

  • Java 8 or higher

  • Maven 3.6 or higher

Build commands

Build the package:

mvn clean package

Run tests:

mvn test

Run all quality checks:

mvn clean verify -Pquality

Development

Code quality

This project uses several tools to maintain code quality:

  • Checkstyle: Code style checking

  • SpotBugs: Static analysis for bugs

  • JaCoCo: Code coverage reporting

  • OWASP Dependency Check: Security vulnerability scanning

Run quality checks:

mvn clean compile -Pquality

Testing

The project includes comprehensive test suites:

  • Unit tests using JUnit 5

  • Integration tests

  • Cross-platform testing on Ubuntu, Windows, and macOS

  • Multi-JDK testing (Java 8, 11, 17, 21)

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Make your changes

  4. Add tests for new functionality

  5. Ensure all tests pass

  6. Submit a pull request

Releasing

Version update

Update version in pom.xml:

<groupId>org.metanorma</groupId>
<artifactId>barcode4j</artifactId>
<version>2.4.0</version>

Release process

  1. Create and push a version tag:

    git tag v2.4.0
    git push origin v2.4.0
  2. The GitHub Actions workflow will automatically:

    • Build and test the release

    • Create GitHub release

    • Deploy to GitHub Packages

License

The original Barcode4J is licensed under the Apache License, Version 2.0. The license text can be found under LICENSE.

Further modifications are copyright Ribose Inc.

About

Fork of barcode4j with maven

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages