Do the page numbers have to be adjacent to each other, or can you skip, say, a bunch of numbers? Here's my silly suggestion: assign each "section" a number from 000 to 999 (or somewhere in between). Then, inside each section, number the pages from 001 to 999 or so. So, when you put all the sections (say, twenty sections, each of five pages) in order, the page numbers are
000001 (000 for section 1, 001 for page 1)
000002
000003
000004
000005
001001 (001 for section 2, 001 for page 1)
001002
and so on...
However...
I'm not as familiar with the PDF and postscript format as I would like to be, but it seems to me that another way of solving this would be to build a generic document. It has headers and footers as you need, and they apply specifically to the document. The footer, of course, includes the page count of the document.
As this is simply a
container, the initial page count is 0.
Make each of your chapters (or however you're dividing your book) such that they contain no header or footer information, just content. But, they must also contain the necessary page breaks and section headers and titles and whatnot.
So, on the server side, you populate your container with the necessary pieces. The container properties include page count.
Okay, in theory, this idea is cool.
In practice, it depends on a few things, such as can PDF support a "container" which can be populated? Can PDF support a piece of dytnamic data in a document? Can a PDF document report its page count to an independent entity (such as your server app). Certainly you can build a postscript page and then pass it through Distiller, but my impression of your parameters is that you would need an online version of Distiller. This is totally possible, but may not be practical for you. And again, can Distiller do a piece of dynamic data such as "NOW how many pages do I have...?"
Another silly option is to figure out what combinations are most likely to occur and (gulp!) post individual PDFs of those on the website. Give 'em a choice of which documents they want. If you need more, hire an intern to make 'em. This can become a support nightmare, of course.
I'm afraid to say that I'm at my limit of knowledge on this one.
Hope that helps at all.
Cheers,
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
Edward
"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door