4.4. Field Value Formats

You can specify the formatting for any field output by the report in the Parameters and Formats tab of the report editor. Below is the form to add a format:

report formatter
Figure 56. Field Value Formats
  • Value name – report field name with the band prefix, for example, Book.year.

  • Format string – field format. For number values specify the format according to the java.text.DecimalFormat rules, for dates – java.text.SimpleDateFormat.

  • Groovy script checkbox – allow specifying a Groovy script to format the parameter. Using the value alias, the current parameter value is passed to the script, which can be formatted or converted to the desired format. A Groovy script should return the new value as a string.

With the help of formats, it is possible to insert images and HTML blocks into the document.

  • In order to insert an image, specify the image URL as the field value, and the format string must be as follows: ${image:<Width>x<Height>}, for example, ${image:200x300}.

    To work with the FileDescriptor, use the ${imageFileId:WxH} value formatter that accepts both the FileDescriptor id and the link to the FileDecriptor instance itself.

  • In order to insert an HTML block, you should return an HTML markup in the field, and select ${html} as the format string. In the output value, you may omit top-level tags up to <body> inclusive. If necessary, all missing top-level tags will be added automatically. All blocks should be encoded with UTF-8. CSS and the style attribute are not supported.

You can specify your own custom formats as well. To do this, type the new value in the field without opening the dropdown and press Enter. You can also choose any format from the dropdown, edit its name in the field and press Enter. Custom format will be saved in both cases.