PDF report template

A report template is necessary to generate files in PDF via Reports or directly on Forms with components like buttons, icons or links. This template must be configured in combination with Jaspersoft, as follows:

  1. Create a report template in IS Tools.

    1. Create a report in Report wizard with the fields you want to include in PDF. In the last window, click on the Separate sheet for report information checkbox.

      If you intend to print information from a single record in the final PDF document, you must tick the Force one main record setting.

      In case you include related records, make sure the fields have unique column names; for example, having a relation Order-Suborder, might be that both tables have a field called "Total"; in that case, edit the name of one of them, e.g., "Invoice total" in the Rename headings window of the Report wizard.

    2. Run the Report in Report manager choosing "Excel 2007" as Format.

    3. Download the report in Report and import queue once is ready.

  2. Create a report template in Jaspersoft.

    1. Open Jaspersoft studio.

      Basically, this tool requires the creation of two elements: the Data adapter (xml file), which is used to import fields from the IS Tools report template, and the Jasper report (jrxml file), which contains the design of the future PDF file. In this way, many Jasper reports can come from a single Data adapter.

    2. Create a Data adapter: Click File on the menu, New, Data Adapter, type the desired File name, then choose Microsoft Excel in the list of Data adapters, and then click on the File button to browse the IS Tools report you downloaded in the previous step. Finish.

    3. Create a Jasper report:

      1. Click File on the menu, New, Jasper Report, type the desired File name, then choose the Data adapter that you created in the previous step, and in the next window, select all fields, and Finish.

      2. In the Outline section, select the report to display its Properties, found at the bottom right section. Under Report, click on Default Data Adapter and browse your Data adapter. OK. Finish.

        In order to avoid internal server errors due to data conversion, make sure the proper class type is chosen for the fields:

        For File fields, set Class Type: java.io.File (for that, click on Edit query, filter and sort options, then double-click the field and enter the class).

        For Number fields, you may set java.lang.Double to display rounded values; otherwise, keep the java.lang.String to display full decimals.

        For Checkbox fields, you may use java.lang.String or java.lang.Boolean.

        For the rest of the fields, keep java.lang.String.

      3. To add a title or a page header, or any label, drag and drop a Static Text from the Palette.

      4. To add images like logotypes or any image not stored in File fields, you must save the images in the Jaspersoft Workspace (i.e., C:...\JaspersoftWorkspace\MyReports). Then drag and drop an Image element from the Palette, and choose Workspace resource. Browse it and then click on OK.

      5. To add fields for multiple records, drag and drop the desired fields (except for File fields, which will only be used as sources for images) from the Outline section to the Detail grid area of the canvas.

        You may change the style of the canvas elements by selecting them and editing their Properties.

      6. To add fields for a single record, select the Column Header grid area of the canvas and delete it. Then drag and drop the desired fields (except for File fields, which will only be used as sources for images) from the Outline section to the Detail grid of the canvas.

        The way you design your PDF file is flexible, for example, you can combine a single record as main data, with multiple related records below, as detailed data.

      7. To add images from File fields, drag and drop an Image element from the Palette, and choose Custom expression, click on the Pencil icon and then click on Fields, then double-click on the wished File (e.g., $F{MyFileField}. Finish. OK.

        After that, go to the Properties of the selected image, and under Image set On error type: Blank. This setting is mandatory to prevent errors due to possible file extensions other than png, jpg, jpeg, etc.

        Add also images of charts and maps stored in File fields.

        You may want to add the name of File as well. For that, add a Text field under the Image, with the Expression getName(), e.g., ${MyFileField}.getName()`

      8. To add barcodes or QR codes, drag and drop a Barcode element from the Palette, and choose the type of your preference. After that, go to its Properties and under Barcode click on the Pencil icon of the Code expression and then click on Fields, and double-click on the field that contains the value of the barcode/QR code (e.g., $F{MyTextField}.

      9. Optionally, add the current date and page number to the footer area.

      10. Make sure the locale setting is according to the default language of the application. For this, click Project on the menu, then Properties, under Jaspersoft Studio click on Report Execution. Click on Use Project Settings and choose the locale in consideration; for example, having French would make numbers be formatted differently than choosing English: 1 234,5 vs 1,234.5 respectively.

      11. Finally, export the report: Click on File, Export, Next, make sure you select the .jrxml file and the logotypes of your report. Browse the location where you want to save it, choose the zip format, and then Finish.

  3. Upload the zipped Jasper report to Report macro files.

  4. Attach the file to the IS Tools report template.

    1. In Report manager, select the source report, click on the Edit icon, and select the previously uploaded file in the Macro/transform box. Save.

  5. Generate the PDF file. There are two options to do it:

    1. Run it from Report manager, choosing "PDF" as Format.

    2. Run it from a form.

      1. To generate it and save it into a File field, in Form designer add a Button component to your form and click on its Run and click property, then type call runReportImmediateAndStore(REPORTID, 'PDF', FILEFIELDNAME), i.e., call runReportImmediateAndStore(100431, 'PDF', "My File Field"). Save.

      2. Or if you prefer to generate it and download it right away, add a Button component to your form and click on its Run and click property, then type call runReportImmediate(REPORTID, 'PDF'). Save.

      3. On the rendered form, click on the Button.

Remarks:

  • Not all functionality from Jaspersoft studio is described above, but only what is supported by the IS Tools reporting tool.

  • The Preview tab in Jaspersoft studio does not reflect the final result of the generated PDF file.

  • There is a limitation on the PDF file size when it includes images. When exceeded, the rest of the images will not be loaded and their placeholders will be displayed as blank.

  • In case the PDF file is generated without being stored into a File field, be aware that reports that take a long time will not be downloaded but placed in the Report and import queue instead, and the user will be notified about this. For that, the user must have rights granted in the Report and import queue form.