java
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.oned.Code128Writer;
import com.google.zxing.client.j2se.MatrixToImageWriter;
public class BarcodeGenerator {
public static void generateBarcode(String data, String filePath, int width, int height) {
try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(data, BarcodeFormat.CODE_128, width, height);
MatrixToImageWriter.writeToPath(bitMatrix, "PNG", new File(filePath).toPath());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
generateBarcode("123456789", "barcode.png", 200, 50);
}
}
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-
上一篇:返回栏目
下一篇:javallonline