testTechie
testTechie

Reputation: 41

How do I create barcode image without containing text at bottom using barbecue library

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"));`

Upvotes: 1

Views: 2142

Answers (2)

Johan
Johan

Reputation: 435

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"));

Upvotes: 0

Sunny
Sunny

Reputation: 103

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"));

Upvotes: 1

Related Questions