5

Adding page numbers in QGIS Layouts can be done with the [% @layout_page %] expression. In Reports, however, the [% @layout_page %] expression always remains "1"

How do we insert the page number in a Report?

0

1 Answer 1

7

We would need a @report_page variable, which at the moment is not available.

However there is a:

Workaround

  1. Create a new integer field in your layer, let's call this field pagenum.
  2. Sort the features by the controlling field (i.e. the one you select as Field in the left pane of the Report editor).
  3. Fill pagenum with sequential numbers, increasing it when the controlling field changes.
  4. Create a label in the Report editor.
  5. Insert the expression [% "pagenum" %].
  6. Export the report.

Page 42 of 314

You can go one step further, and insert an expression to compute the total number of pages:

Page number: [% "pagenum" %] of [% count_distinct( "pagenum" ) + 1 %]

The + 1 here is for taking into account the header page, if any.

enter image description here

1
  • I don't see how i could use this solution in the case i told you in my previous question ... or maybe i'm getting something wrong ...
    – Snaileater
    Commented Jun 23, 2019 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.