Excluding controls from generated form PDFs

Last updated on August 2, 2022

You can exclude controls (fields) from the autogenerated PDFs that Orbeon produces.

When to use this script

  • When building a 'navigator' form that presents results to a user and you want them to be able to download the results without all the questions included
  • When building a 'knowledge test' form and you want to exclude things like images or explanatory text
  • Any other situation when you want to exclude an item from the autogenerated result due to irrelevance, space or some other reason

What this script does

This script hides (excludes) the control from the autogenerated PDF output.

The script

fr:mode() != 'pdf'

TIP: You can 'inverse' this script (fr:mode() = 'pdf') for the opposite effect. You can use this to show a control on the PDF but not on the form. This could be useful for things like providing feedback to knowledge tests, compiled address blocks, etc.

You can also use this to create a "double-form" that contains the controls presented in one way to the user, and another way in the PDF. This effectively means you are creating two 'versions' of the form, one above the other. The 'first' form presents the controls in a vertical format for ease of the user, while the 'second' lays the data collected from the user in an easier to read or print traditional pattern.

How to use this script

  1. Select a control you want to exclude from the autogenerated PDF output.
  2. In the control's settings, select the Formulas tab.
  3. Paste the script in the Validation Details field of the Formula (shown below).
  4. Click the Apply button.

TIP: You can also apply this script at the Section level to hide the section and all its controls from the PDF. This can save you time and effort, and will remove the section heading from the PDF as well.

Results

Sample form with two controls (fields) displayed:

Default PDF with both fields:

New PDF with first control excluded: