How to reduce wide-factor in EAN13 barcode text without modifying font size in Barcode4j?

37 Views Asked by At

I am using the Barcode4j library in Java to generate EAN13 barcodes. The barcode is generated successfully, and I have added text at the bottom of the barcode. However, I want to reduce the space between characters in the text without modifying the font size.

Currently, I achieve the desired spacing by adjusting the font size, but I prefer not to modify the font size. Is there a way to reduce the wide-factor in the EAN13 barcode text using the Barcode4j library?

Here is a snippet of my code:

EAN13Bean ean13 = new EAN13Bean();
ean13.setBarHeight(4);
ean13.setModuleWidth(0.3);
ean13.doQuietZone(true);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
BitmapCanvasProvider canvas = new BitmapCanvasProvider(baos, "image/x-png", 300, BufferedImage.TYPE_BYTE_BINARY, false, 0);
ean13.generateBarcode(canvas, myString);
canvas.finish();

FileOutputStream fos = new FileOutputStream("\\Temp\\BarcodeImages\\" + image_name);
fos.write(baos.toByteArray());
fos.flush();
fos.close();

Is there a parameter or method in Barcode4j that allows me to adjust the wide-factor for the text without changing the font size? If not, are there any alternative approaches to achieve this goal?

0

There are 0 best solutions below