2013-02-22 20 views
1

我出口現有的圖像DynamicReports現有圖像:與dynamicreports

public class DReportSample { 

    public DReportSample() { 
     build(); 
    } 

    private void build() { 
      StyleBuilder boldStyle   = stl.style().bold(); 
      StyleBuilder boldCenteredStyle = stl.style(boldStyle).setHorizontalAlignment 
        (HorizontalAlignment.CENTER); 
      //BufferedImage img = new BufferedImage(1200,1200,BufferedImage.TYPE_INT_RGB); 
      BufferedImage img = null; 
try { 
    // img = ImageIO.read(new File("D:/Hysteresis.png")); 
    img = ImageIO.read(new File("D:/Hysteresis.png")); 
} catch (IOException e) { 
} 
     try { 
      report()//create new report design 
         // .setColumnTitleStyle(boldStyle) 
         // .setColumnStyle(boldStyle) 
          .highlightDetailEvenRows() 
       .columns(//add columns 

       col.column(null,"Col_1",  type.stringType()), 
       col.column(null,"Col_2", type.stringType()) 
           ) 
          .summary(
     cmp.verticalList() 
      .add(cmp.text("\n\nHYSTERISIS PLOT").setStyle(boldStyle)) 

      .add(cmp.image(img)) // Add the exported chart image to the report. 

    ) 
       .title(cmp.text("XYZ Hospital").setStyle(boldCenteredStyle))//shows report title 
       .pageFooter(cmp.pageXofY())//shows number of page at page footer 
       .setDataSource(createDataSource())//set datasource 
       .show();//create and show report 
     } catch (DRException e) { 
      e.printStackTrace(); 
     } 
    } 

但問題是圖像似乎是固定大小的說(300,300)像素。我希望它出現更大的尺寸,

我試圖手動調整圖片的大小,以它的兩倍大小,然後使用上面的代碼,但它再次出現了同樣大小的(300,300)

於是我試圖用調整和版本通過我的代碼嘗試:

BufferedImage img = new BufferedImage(1200,1200,BufferedImage.TYPE_INT_RGB); 

,但它沒有工作:

然後我嘗試:

.add(cmp.image(img.getScaledInstance(600, 600, 5))) 

它使圖像顯得更小。

有人可以讓我知道如何導入我的dynamicreports文件中的圖像與我所需的維度。也請指導,我如何更改我的文本的字體樣式,顏色和大小。

感謝

回答

3

。新增(cmp.image(IMG).setFixedDimension(500,400))

解決了這個問題。

有人能告訴我如何在dynamicReports中更改我的文本的字體樣式,顏色和大小