Insert automatic page numbers in headers and footers.
Dynamic page numbering that updates as document changes, with total page count support.
OOXML Structure
<!-- Page number field -->
<w:fldSimple w:instr="PAGE">
<w:r>
<w:t>1</w:t>
</w:r>
</w:fldSimple>
<!-- Total pages field -->
<w:fldSimple w:instr="NUMPAGES">
<w:r>
<w:t>10</w:t>
</w:r>
</w:fldSimple>
Use case
- Professional documents - Standard page numbering
- Reports - Page X of Y format
- Legal documents - Required pagination
- Print layouts - Automatic page tracking
- Dynamic updates - Numbers adjust as content changes
Options
Configure the extension behavior:
HTML attributes for page number elements
Commands
addAutoPageNumber
Insert an automatic page number
Only works in header/footer contexts
Example:
editor.commands.addAutoPageNumber()
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';
const superdoc = new SuperDoc({
selector: '#editor',
document: yourFile,
onReady: (superdoc) => {
const editor = superdoc.activeEditor;
editor.commands.addAutoPageNumber()
},
});
Returns: Function Command function
addTotalPageCount
Insert total page count
Only works in header/footer contexts
Example:
editor.commands.addTotalPageCount()
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';
const superdoc = new SuperDoc({
selector: '#editor',
document: yourFile,
onReady: (superdoc) => {
const editor = superdoc.activeEditor;
editor.commands.addTotalPageCount()
},
});
Returns: Function Command function
Keyboard shortcuts
| Command | Shortcut | Description |
|---|
| addAutoPageNumber() | ⌘/Ctrl-Shift-Alt-p | Insert page number |
| addTotalPageCount() | ⌘/Ctrl-Shift-Alt-c | Insert total page count |
Source code