我用烧烤制作了一个条形码图像。创建图像时,我可以看到我在该图像中创建的条形码。我只想看看条形码。

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);
}
}发布于 2016-07-13 00:15:05
请注意,Barbecue似乎被放弃了,而且它对AWT这样的类有很强的依赖性,这使得它不适合例如Android开发。但是,您应该能够对drawingText属性执行您想要的操作:
指示条形码数据是否应显示为条形码下的字符串。 注意,在绘制条形码之后更改此设置将使组件无效,并可能强制刷新。
barcode.setDrawingText(false);https://stackoverflow.com/questions/38340702
复制相似问题