Page numbering by section in a PDF

How can I restart the page numbering in different sections of a PDF? I need the first twenty-five pages of the document to be numbered 1-25, then the last two pages numbered 1-2, in one PDF. How can I do that?

This is not an easy solution but you might be able to do it if you define the last two pages as Back Matter - because you can have a different header and footer applied to the back matter. You would need to put those pages in a separate folder. Then define that folder as Back Matter in the main compile window. Then edit the compile format and go to Page Settings, Check ‘Different header and footer for back matter’ and then go to header and footer text and put the page number placeholder in.

I’m not sure the numbering would restart at 1 again but, apart from manually editing the PDF in something like Adobe Acrobat, I can’t think of another approach. Page 575 of the Scrivener manual covers Front & Back Matter. If the page number placeholder just continues on from 25 try the number placeholder - <$n>

I don’t know if this works for the <$p> tag, but try this:
Put <$rst><$p> into the top of the document that you want to reset the page numbers on and see if it resets the pages.

Alternately, if the page number reset happens when you come to a new section, and you mark those section containers with a Section Type different from the rest of your documents, then you can modify compile to add <$rst><$p> as a separator before each of those sections. Assuming that the first experiment works.

First experiment, putting <$rst><$p> at the top of the page I wanted the numbering to restart did not work. It just left me with “??” in its place and the numbering continued as usual.