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?
Answer
We would need a @report_page
variable, which at the moment is not available.
However there is a:
Workaround
- Create a new integer field in your layer, let's call this field
pagenum
. - Sort the features by the controlling field (i.e. the one you select as
Field
in the left pane of the Report editor). - Fill
pagenum
with sequential numbers, increasing it when the controlling field changes. - Create a label in the Report editor.
- Insert the expression
[% "pagenum" %]
. - 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.
No comments:
Post a Comment