2015-02-07 83 views
0

我正在使用DynamicReport 4.0和下面的代碼來打印標籤。但是我無法增加條形碼的寬度。有什麼方法可以增加動態報告中條形碼的寬度?DynamicReport條形碼寬度問題

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

找到解決辦法,我們必須用setModuleWidth(Double)。對於上面的代碼,它將是,

DynamicReports.bcode.code128("T7170B1000").setModuleWidth(3d).setStyle(DynamicReports.stl.style().setHorizontalAlignment(HorizontalAlignment.CENTER))