The Printer has no way to "know" how many pages are coming.
The software (like MSWord) usually has a page count and that is the one who places the X of XX pages at the bottom of the paper.
Otherwise, if your printer is EXTREMELY sophisticated (read expensive) it will spool the entire print job in its local memory, count the number of FORM FEEDs (which are provided by the software application) and can then deduce the number of pages.
The printer/computer communications is different depending on the connection (Parallel, serial, network)
Suffice it to say, the Computer sends out a WORD (not an English word) and the Printer can queue data (spool) locally and tell the application when to 'hold on Bobaluey' if it is coming too fast.