我正在使用DynamicReport 4.0和以下代码来打印标签。但我不能增加条形码的宽度。有没有办法在动态报告中增加条形码的宽度?
private ComponentBuilder<?, ?> getList(String title, String content){
return DynamicReports.cmp.horizontalList(DynamicReports.cmp.text(title), DynamicReports.cmp.text(":"), DynamicReports.cmp.text(content));
}
private void showLabel(){
JasperReportBuilder report = DynamicReports.report();
TextFieldBuilder<String> heading = DynamicReports.cmp.text("XYZ Company Ltd.");
StyleBuilder headingstyle= DynamicReports.stl.style().setFontSize(16).setBold(true).setUnderline(true).setAlignment(HorizontalAlignment.CENTER, VerticalAlignment.TOP);
heading.setStyle(headingstyle);
report.setPageFormat(283, 425, PORTRAIT);
report.setPageMargin(DynamicReports.margin().setLeft(14).setTop(14).setRight(14).setBottom(14));
report.setTemplate(DynamicReports.template().setBarcodeWidth(400).setBarcodeHeight(40));
//report.title(heading);
VerticalListBuilder list = DynamicReports.cmp.verticalList();
list.setGap(15);
list.add(
heading,
getList("Client", "Anirban Chakraborty"),
getList("Batch No.", "T7170B1000"),
getList("Drawing No.", "51004A-777777-0111-B1000"),
getList("Mark No.", "170B1000"),
getList("Qty.", "1"),
getList("Part Sr. NO.", "1/1"),
getList("Rev.", "1.0"),
getList("Wt.", "1.900"),
DynamicReports.bcode.code128("T7170B1000").setStyle(DynamicReports.stl.style().setHorizontalAlignment(HorizontalAlignment.CENTER))
);
report.title(list);
try{
report.show(false);
}catch(DRException e){
e.printStackTrace();
}
}
答案 0 :(得分:0)
找到解决方案,我们必须使用setModuleWidth(Double)
。对于上面的代码,它将是,
DynamicReports.bcode.code128("T7170B1000").setModuleWidth(3d).setStyle(DynamicReports.stl.style().setHorizontalAlignment(HorizontalAlignment.CENTER))