How To Dynamically Resize Image

This recipe shows how to dynamically resize image by changing the parameters of width and height using Java code.

Major steps include the following:

  1. Create a report template (demo.rml) and add the image (elite.jpg) under “Section Header”.
  2. Add the following parameters into “Report > Parameters”:(Param1) Name=myWidth, Value=${myWidth##1000}
    (Param2) Name=myHeight, Value=${myHeight##1000}
  3. Right-click the image and add the following code into “Properties > Scripts > On Render Begin”:this.setWidth(Properties.getProperty(“myWidth”));
    this.setHeight(Properties.getProperty(“myHeight”));

Screenshot of setting dynamic parameters:

HowToDynamicResizeImage

Screenshot of rendered output:

HowToDynamicResizeImage2

To download the necessary files for this recipe, refer to the attached ZIP package.
HowToDynamicResizeImage.zip (8.8 KB)