Java generate the barcode without text on the barcode image
Tags: barcode, java, barcodeimage
Published: 2021-07-28 07:54:52

---
title:Java generate the barcode without text on the barcode image
published: true
description: generate barcode without text data, QR code, barcode
tags: barcode, java, barcodeimage
//cover_image: https://direct_url_to_image.jpg
---

This guide will show you how to generate Barcode & QR code with the invisible the textual data using Spire.Barcode for Java.

Installing Spire.barcode jar

If you create a Maven project, you can easily import the jar in your application using the following configurations. For non-Maven projects, download [the Barcode jar](https://www.e-iceblue.com/Download/barcode-for-java.html) file and add it as a dependency in your application.

```java
<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId> e-iceblue </groupId>
        <artifactId>spire.barcode</artifactId>
        <version>4.1.2</version>
    </dependency>
</dependencies>
```

Generate a 1D barcode without the Text Data When Creating a Barcode

```java
import com.spire.barcode.BarCodeGenerator;
import com.spire.barcode.BarCodeType;
import com.spire.barcode.BarcodeSettings;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class CreateBarcode {
    public static void main(String[] args) throws IOException {
        //Instantiate BarcodeSettings object
        BarcodeSettings settings = new BarcodeSettings();
        //Set the Barcode type
        settings.setType(BarCodeType.Codabar);
        //Set the Barcode data
        settings.setData("123456789");
        //Make the textual data invisible
        settings.setShowText(false);
        //Make the textual data visible at the Barcode
        settings.setShowTextOnBottom(true);
        //Set width for the black and white stripes
        settings.setX(0.8f);
        //Set height for the created Barcode image
        settings.setImageHeight(50);
        //Set width for the created Barcode image
        settings.setImageWidth(70);
        //Make the border visible
        settings.hasBorder(true);
        //Set the border color
        settings.setBorderColor(new Color(135,206,250));
        settings.setBorderWidth(1);
        settings.setBackColor(new Color(240,255,255));

        //Instantiage BarCodeGenerator object
        BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);
        //Generate image data based on settings and save it to BufferedImage instance
        BufferedImage bufferedImage = barCodeGenerator.generateImage();
        //Save the Barcode as PNG
        ImageIO.write(bufferedImage, "png", new File("Codabar.png"));
    }
}
```
Output:
![1D barcode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ty3i79ux0muawd3cta35.png)

Generate a QR code without the Text Data When Creating a Barcode

```java
import com.spire.barcode.*;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class CreateQR {
    public static void main(String[] args) throws IOException {

        //Instantiate BarcodeSettings object
        BarcodeSettings settings = new BarcodeSettings();
        //Set Barcode type as QR code
        settings.setType(BarCodeType.QR_Code);
        //Set the data 
        settings.setData("Hello 123456789");
        // Make the textual data invisible
        settings.setShowText(false);
        settings.setQRCodeDataMode(QRCodeDataMode.Alpha_Number);
        settings.setImageWidth(50);
        settings.setImageHeight(50);
        settings.setX(3.0f);
        settings.setQRCodeECL(QRCodeECL.H);
        //make the border invisible
        settings.hasBorder(false);
        //Instantiage BarCodeGenerator object
        BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);
        //Generate image data based on settings and save it to BufferedImage instance
        BufferedImage bufferedImage = barCodeGenerator.generateImage();
         //Save the QR code as PNG
        ImageIO.write(bufferedImage, "png", new File("QRCode.png"));
    }
}
```
Output:

![QRcode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zogjmvxygpfyc48bk9f.png)