I would like to display a background or another depending on two variables: total pages and number page, such as:
How should I modify the report template?
You have some defined variables in your report, as PAGE_NUMBER Use them in the Option "Print when expression" of your element to show it. (see screenshot)