Double pass mode

Double pass mode is a report option that changes how the report engine runs. When double pass mode is enabled, the report is processed twice. The two runs are called the primary (test) pass and the secondary (real) pass. In the test pass, the report is rendered to an invisible "null" output, so nothing is printed, but the engine learns the final layout, including the total number of pages. The real pass then renders the report to the actual output, already knowing the results of the test pass.

Why is double pass mode necessary? In normal (single pass) mode, the report engine simply runs the report from beginning to end without any look-ahead, so information such as the total number of pages is not available while the pages are being rendered.

The pagecount system variable always returns zero in single pass (normal) mode. If you need the pagecount system variable, you have to enable double pass mode.

Double pass mode has the following additional effects:

  • The Break to next page if singular option of group headers takes effect only in double pass mode (see Page Breaks).

  • With endless paper, the height of the output is adjusted to the final position measured in the test pass.

Since the report is processed twice, double pass mode increases the running time of the report. Enable it only when you need it. Double pass mode applies to normal reports only; in Text Document mode, the page count is available anyway.

Setting double pass mode

The double pass option is one of the report options that are saved in the report definition (as the doublePass option). To enable or disable it in the Designer, select Report  Report and page settings…​ and turn on the Double pass mode option in the Working mode panel of the General tab. For more information, see "Setting up page and report options" in the Designer part.

Example using the pagecount variable

Use the $V{pagecount} expression in a field in expression or template mode, or in a text item in template mode.

Expression mode example: $V{pagecount}

Template mode example: Page $V{pageno} of $V{pagecount}

The sqlite_productlist_grouped_doublepass.xml demo report uses double pass mode.