Forum How do I...?

Reseting pages counter

sunblaze
Hi,

I need to be able to define sections of a document that should not be included in the pages counter. I was able to reset the page counter but not the pages counter. I need the pages counter because they want the format "Page x of y" but the y always reflects the total pages in the document.

Here's what I have so far.

.header .page_numbers {
font-weight: bold;
content: "Page " counter(page) " of " counter(pages)
}

.contents {
counter-reset: page 1;
}
sunblaze
Well I found a solution. So I figured I'd post it just to make sure there's nothing wrong with it and if anyone else runs into the same problem I did they can use it as a reference.

Instead of using the pages counter I add a div with an id of end and used the target-counter function to get the value of the page counter at that div.

Here's the code.
.header .page_numbers {
	font-weight: bold;
	content: "Page " counter(page) " of " target-counter("#end",page)
}
.contents {
	counter-reset: page 1;
}

<div>
Title Page
</div>
<div>
	<div>
	TOC
	</div>
	
	<div>
	Second Page
	</div>
</div>

<div>
</div>
mikeday
That's a very clever solution! :D