質問

I am exporting an existing image to 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();
        }
    }

But the problem is the image appears to be fixed size say (300,300) pixels. I want it to appear as bigger size,

I tried to resize my image to its double size manually, and then using above code but it again appeared of same size(300,300)

Then I tried to use resized version through my code and tried:

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

but it did not work:

Then I tried:

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

it made the image appear even smaller.

Can some one please let me know how do I import the image in my dynamicreports file with my desired dimension. Also please guide, how do i Change font style,color and size of my text.

Thanks

役に立ちましたか?

解決

.add(cmp.image(img).setFixedDimension(500, 400))

resolved the issue.

Can someone tell me how to change font style,color and size of my text in dynamicReports

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top