Tuesday 29 March 2016

Adding page number in QGIS Report?


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



  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



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...