To generate an Image from an HTML report you have to configure the next steps:

  1. set the option <generateImage><format>format</format></generateImage> in the declarations section of the report module

    <reports ......>
     <declarations>
       <chartFormat id="chartFormat1"> ....    </chartFormat>
       <summaryFormat id="formatStatusMap"> ....    </summaryFormat>
       <htmlTableFormat id="htmlTableFormat1NL" tableStyle="tableStyle1"> ....    </htmlTableFormat>
       <dateFormat id="dateFormat1"> ...  </dateFormat>
       <numberFormat id="numberFormat1"> ... </numberFormat>
    
       <generateImage>
         <format>jpg</format>
         <options>--width 720 --quality 50</options>
       </generateImage>
    
       <templateDir>$REPORT_TEMPLATE_DIR$</templateDir>
       <reportsRootDir>$REPORT_ROOT_DIR$</reportsRootDir>
       <reportsRootSubDir>nl/fluvial</reportsRootSubDir>
    
       <sendToLocalFileSystem>true</sendToLocalFileSystem>
    
       <timeZone ..
       <locale ....
     </declarations>
    
  2. Note that the option sendToLocalFileSystem should be set to true. To generate an Image from reports (zip files) stored in the database, you can configure a similar option in the ReportExport configuration.
  3. in the global.properties the option REPORT_HTML2IMG_PROGRAM should be defined.
    For example to REPORT_HTML2IMG_PROGRAM=%REGION_HOME%/Modules/Reports/bin/wkhtmltoimage.exe

The generateImage element has two configuration elements:

format

Configure the output format, by giving the three-letter file extension typically used, The image formats supported by wkthtmltoimage are JPG, PNG, SVG, BMP. The default format is JPG.

options

Configure specific options, that are to be added to the command line (before the input / output arguments). Typically this is used to control image size and quality, as in the example given above.


Currently the wkhtmltoimage program is used, which is available for windows and various linux distributions

N.B.: The html to image conversion tool will be run with 2 arguments, ie. wkhtmltoimage <input-html file> <output-image-file> and in order to be able to add specific program options, an <options> element can be added that inserts the options given on the command line (before the 2 input / output arguments).

The image formats supported by wkthtmltoimage are jpg, png, svg, bmp.

 


  • No labels