This "bug" is due to CSS counter scope issues, so is not technically a bug in Confluence itself. That said, numbering is a pretty important (dare I say essential) feature of a large PDF export, so it'd be great if Atlassian can find a solution and make it work.
Firstly, CSS scope counters are magical things which depend heavily on scope. This allows them to automatically nest and be used in properly formatted nested HTML layouts. Confluence, however, does not nicely format or nest the HTML and thus things break. When resetting a counter, this sets the scope for that counter to sibling elements, or child elements. This suits the Table of Contents because everything is on the same level within the container div. Each reset is within the right scope of the next elements, and everything just works.
Things get difficult when dealing with page headers. Each header tag (<h*>) for each page-header and the page-content headings are wrapped separately in .wiki-content and .pagetitle div's per page (i.e. one for the page-header, one for the page-content). This means that although you can increment and reset counters within each page-content block, any resets within this scope are not applied to the next page - and things reset to 0 or keep going up, depending. Sound confusing? It is...
Ultimately this means that you can reset individual counters globally (say on the <body> tag), or locally within each page... The former limits you to only numbering headings for individual pages, while the latter limits you to only numbering headings within pages.
Although I haven't tested it (yet), it should be possible to set up the numbering system using both global and local scope - but only for single level pages for the entire document. You'd then rely on global scope of the page headings, and reset the content headings within each .wiki-content block. In theory this would do the trick, but removes the benefits if nesting pages to reduce down long pages into shorter pages, for ease of editing.
Ultimately, a better solution (and a lot simpler for users) would be if there was an option when generating the PDF to enable heading numbers. Confluence then works out the numbers and rather than using CSS magic trickery, adds them as actual content during generation. Numbering would just work, and everyone would be happy. The current situation sucks and makes PDF generation look very unprofessional.
(I'm running a local Confluence 5.6.1 install)
Hi everyone,
Thank you for previously raising this bug and bringing it to our attention.
Within our company roadmap and work capacity, we try to address or review each bug request but admit that not each one will be resolved. To continue the culture of being honest and open, we are closing this bug to focus on our upcoming roadmap for all Confluence users.
As we continue to roll out features we do look at requests made by our users and if you feel like this bug is still impacting your team please let us know.
Thank you again for providing valuable feedback to our team!