Forum How do I...?

Total pages per section

This is a followup or related to

My document contains several repetitive elements like

    <section class="account-statement">
        <div class="end"></div>

In the bottom of each page I need to print "Page x of y":

    @bottom-right {
        content: "Page " counter(page) " of " target-counter(url(.end), page);

I reset the counter for each section using

account-statement {
    page: statement;
    counter-reset: page 1;

and the out is alway "Page 1 of 0", "Page 2 of 0", ....

So somehow the target-counter() call does not work as expected.

Any idea?

Edited by yet

Unfortunately url(.end) will not work, it will need to be an actual unique ID, #statement594 or something like that. You could add such IDs with JavaScript.
Generating unique IDs would not be a problem. But how would you configure the individual content: rules with the related generated IDs?
That might be slightly awkward, it might require a separate named page for each section.