我使用barccode4j生成条形码图像并在jasper报告中打印。当pring 13数字包含字符或在得分符号下时,生成的图像宽度太长。这是我的代码
final int dpi = 203;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
BitmapCanvasProvider bitmapCanvasProvider = new BitmapCanvasProvider(
byteArrayOutputStream,
"image/x-png",
dpi,
BufferedImage.TYPE_BYTE_BINARY,
true,
0
);
Code128Bean bean = new Code128Bean();
bean.setModuleWidth(UnitConv.in2mm(2.8f / dpi));
bean.doQuietZone(false);
bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
bean.generateBarcode(bitmapCanvasProvider, barcodeNumber);
bitmapCanvasProvider.finish();
reportModel.setBarcodeStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));