Forum How do I...?

Can the 'pages' counter be reset to only count a section of a document?

quiredan
We're using Prince to generate PDFs that have 3 main sections: Intro pages, Report body, and Appendices.

I'm trying to get the total page count to display on the Report Body and only count the total pages in that section. Is that possible?

I can get it to start counting at the report body but even if I reset it at the Appendix it still counts those pages. Maybe I'm not understanding how it works.
mikeday
In that case you cannot use the pages counter, but you could link to the last page of the report body and use target-counter() to check the page number of that page.
quiredan
I got the target-counter method to work but I'm still getting the wrong page number. Should I be able to include the link directly in target-counter() instead of using attr(href)? Like this:

content: target-counter("#end", page);


In the TOC the last page of the body is showing as 20. I'm seeing 26 using target-counter(). And the actual last page number is 24 (there are 4 pages before the report body, which resets the page counter to 1).

Any idea what I'm doing wrong?

Edited by quiredan

mikeday
Tricky, would you be able to email me (mikeday@yeslogic.com) a sample document?
quiredan
I actually got it working by using an actual link so I could use attr(href). Before I was just trying to set the content property of a div so I had to add the anchor manually.

If I can reproduce the issue I'll send you something, but so far I haven't been able to. It's in a client document that I'm not able to share.

Thanks for the help though :)
quiredan
Just wanted to follow up on this... the way I originally described this actually works. I just had to reset the pages counter on a different element.

I'm not sure why it was necessary, but basically the Appendices section is structured like this:

<ol class="appendices">
  <li class="appendix">
    Appendix contents here
  </li>
</ol>


Resetting the counter on the ol.appendices element doesn't work, but resetting on li.appendix does. Just figured it was worth mentioning in case there's a bug here or something.

Edited by quiredan