How to generate PNG barcodes in Java using the zxing library:
Using the zxing library in the pom:
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.2</version>
</dependency>
it is possible to generate a PNG barcode in various formats like this:
Path barcode = tempDirectory.resolve("barcode.png");
BitMatrix bitMatrix = new Code39Writer().encode("data", BarcodeFormat.CODE_39, 204, 70);
MatrixToImageWriter.writeToPath(bitMatrix, "png", barcode);