In this tutorial, we are going to introduce how to invisiblize the textual data in the middle of creating a Barcode&QR code using Spire.Barcode for Java and its settings.setShowText(false); method.
Invisiblize the Textual Data When Creating a Barcode
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 {
BarcodeSettings settings = new BarcodeSettings();//Instantiate BarcodeSettings object
settings.setType(BarCodeType.Codabar);//Set the Barcode type
settings.setData("123456789");//Set the Barcode data
settings.setShowText(false);//Make the textual data invisible
settings.setShowTextOnBottom(true);//Make the textual data visible at the bottom of the Barcode
settings.setX(0.8f);//Set width for the black and white stripes
settings.setImageHeight(50);//Set height for the created Barcode image
settings.setImageWidth(70);//Set width for the created Barcode image
settings.hasBorder(true);//Make the border visible
settings.setBorderColor(new Color(135,206,250));//Set the border color
settings.setBorderWidth(1);//Set the border width
settings.setBackColor(new Color(240,255,255));//Set background color for the Barcode
BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);//Instantiage BarCodeGenerator object
BufferedImage bufferedImage = barCodeGenerator.generateImage();//Generate image data based on settings and save it to BufferedImage instance
ImageIO.write(bufferedImage, "png", new File("Codabar.png"));//Save the Barcode as PNG
}
}
Output

Invisiblize the Textual Data When Creating a QR code
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 {
BarcodeSettings settings = new BarcodeSettings();//Instantiate BarcodeSettings object
settings.setType(BarCodeType.QR_Code);//Set Barcode type as QR code
settings.setData("Hello 123456789");//Set the data
settings.setShowText(false);// Make the textual data invisible
settings.setQRCodeDataMode(QRCodeDataMode.Alpha_Number);//Set data mode
settings.setImageWidth(50);// Set widthfor the created QR code image
settings.setImageHeight(50);// Set height for the created QR code image
settings.setX(3.0f);//Set width for QR code model
settings.setQRCodeECL(QRCodeECL.H);//Set QR code ECL
settings.hasBorder(false);//make the border invisible
BarCodeGenerator barCodeGenerator = new BarCodeGenerator(settings);//Instantiage BarCodeGenerator object
BufferedImage bufferedImage = barCodeGenerator.generateImage();//Generate image data based on settings and save it to BufferedImage instance
ImageIO.write(bufferedImage, "png", new File("QRCode.png"));//Save the QR code as PNG
}
}
Output

