1

I want to generate a barcode.png file but the file generated contains the Barcode number also and I don't want that, I only want image without Text.

How to do that? Below is my code:-

Barcode barcode3;
barcode3 = BarcodeFactory.createCode128("CODE128x1");
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-1.png"));`
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
testTechie
  • 41
  • 6

2 Answers2

1

The text will not generate in case you pass the null parameter to setFont function of Barcode class. Your code looks like as below

    Barcode barcode3;
    barcode3 = BarcodeFactory.createCode128("CODE128x1");
    barcode3.setFont(null);
    barcode3.setResolution(300);
    BarcodeImageHandler.savePNG(barcode3, new File("Code128-1.png"));
Sunny
  • 103
  • 8
0

only adding this to your code :

barcode3.setDrawingText(false);

the method above will remove text from the barcode. full code

Barcode barcode3;
barcode3 = BarcodeFactory.createCode128("CODE128x1");
barcode3.setDrawingText(false);
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-1.png"));
Johan
  • 207
  • 4
  • 14