Search code examples
javaencodingbarcode-scannercode128barbecue

I dont want to see the bar code name in my bar code image


I have created a barcode image using barbecue. when image is created i can see the code i have created the bar code in that image too. i only want to see the bar code.enter image description here

    import java.io.File;
    import net.sourceforge.barbecue.BarcodeFactory;
    import net.sourceforge.barbecue.BarcodeImageHandler;

    /**
     *
     * @author malinda
     */
    public class NewClass {

    public static void main (String [] args) throws Exception {

    //Get 128B Barcode instance from the Factory
    net.sourceforge.barbecue.Barcode barcode = BarcodeFactory.createCode128B("be the coder");
    barcode.setBarHeight(20);
    barcode.setBarWidth(1);

    File imgFile = new File("testsize2.png");

    //Write the bar code to PNG file
    BarcodeImageHandler.savePNG(barcode, imgFile);
      }
    }

Solution

  • Be aware that Barbecue appears to be abandoned, and it has hard dependencies on classes such as the AWT that make it unsuitable for, e.g., Android development. However, you should be able to do what you want with the drawingText property:

    Indicates whether the barcode data should be shown as a string underneath the barcode or not.

    Note that changing this setting after a barcode has been drawn will invalidate the component and may force a refresh.

    barcode.setDrawingText(false);