package com.prophesy.service.impl;
import org.apache.commons.lang.ObjectUtils;
import org.krysalis.barcode4j.HumanReadablePlacement;
import org.krysalis.barcode4j.impl.code128.Code128Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import java.awt.image.BufferedImage;
import java.io.*;
public class TestBarcode {
/**
* 生成条形码文件
*
* @param msg 条形码的文本内容
* @param path 生成条形码的文件路径
* @return
*/
public static File generateFile(String msg, String path) {
File file = new File(path);
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
generateBarCode128(msg, 25.0, 0.3, true, false, outputStream);
} catch (Exception e) {
throw new RuntimeException(e);
}
return file;
}
/**
*
生成条形码(版本二) 亲测有效
于 2022-06-14 17:51:30 首次发布