Template based reports

When creating HTML template based reports, pdfToolbox creates an intermediate HTML file from which the PDF report is created. Some additional information that can be taken up by the report (via JavaScript) is exported into "./scripts/cals_params.js". Some information is always exported, if information requires processing time or disk space, however, it is only exported if ordered in a file "manifest.xml" that is present in the template folder.

The manifest.xml also allows for keeping the intermediate HTML when it contains the following line

<x:keeptemp>true</x:keeptemp>

If not, it will be deleted after the PDF report has been generated.

Some new information is available in pdfToolbox versions beginning with version number 10.

Page numbers for hits

For each hit a new "on_pages" array identifies all pages that have a certain hit. E.g.

"on_pages" : [ 6, 15, 17, 18, 19, 20, 35, 36, 37, 39 ],

This information can be taken up in a report such as in this example.

The download zip below contains this report template. It can be copied into the template folder and will then show up in the "Settings PDF report (Custom)" Pop up as "PDF report (Overview) with black page numbers" (only difference to the above is that the pages are indicated in black).

More page previews

More than one page preview can be exported by pdfToolbox when the manifest.xml has an entry:

<x:preview resolution="100" firstPage="1" lastPage="30"/>

Up until pdfToolbox 10 only one page preview could be created which was indicated by:

<x:preview resolution="20" page="1"/>

Images are exported into the file system as png files. The folder in the intermediate HTML is:

./img/cals_pages/../../cals_src_a.png

To create previews of all pages, the "lastPage" parameter can be set to "-1".
The links to the pages are also listed in cals_params.js.

Accessing variable values

It is also possible to add various other information to template based reports. A very flexible way to do so is using variables. Beginning with pdfToolbox 10 the cals_params.js file contains in the variable "cals_res_info" an object "vars" that has key value pairs of all variable values that have been used in the Profile from which the report was created.

This allows for adding almost all arbitrary information to the report.

The example below contains two parts:

  1. A Process Plan that
    • Checks for any images where the image resolution is not 300 ppi
    • For all pages with hits an entry in an array variable "app.vars.result_array" is created that lists all image resolutions
    • Then all images are resampled to 300 ppi
  2. A report template that can be installed in the template folder and will then show up in the template pop up as "PDF report (Overview) with text from "result_array".
    • It adds a new section to the report with additional information.
    • The headline for this section is taken from a variable "app.vars.headline" if defined, otherwise it is "Additional information".
    • Each entry in "app.vars.result_array" makes  for an additional line in the report.

The report template may be used with other Process Plans which should then define app.vars.headline and app.vars.result_array.

0 Comments

Send Your Comment

E-Mail me when someone replies to this comment