我不想在我的条码图像中看到条码名称
I dont want to see the bar code name in my bar code image
我使用烧烤创建了条形码图像。创建图像后,我也可以看到我在该图像中创建条形码的代码。我只想看条形码。
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);
}
}
请注意,Barbecue 似乎已被废弃,并且它对 类(例如 AWT)具有硬依赖性,因此不适合 Android 等开发。但是,您应该可以使用 drawingText
属性:
做您想做的事
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);
我使用烧烤创建了条形码图像。创建图像后,我也可以看到我在该图像中创建条形码的代码。我只想看条形码。
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);
}
}
请注意,Barbecue 似乎已被废弃,并且它对 类(例如 AWT)具有硬依赖性,因此不适合 Android 等开发。但是,您应该可以使用 drawingText
属性:
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);