r7_docx_header_footer
Read, create, or update DOCX headers and footers while preserving existing fields such as PAGE, NUMPAGES, and DATE. Add page numbers safely without overwriting field runs.
Instructions
Read, create or re-text DOCX headers and footers. A text change rewrites only the non-field runs of the paragraph and keeps every field (PAGE, NUMPAGES, DATE…) exactly where it was, so a page number is never destroyed. Page-number fields are added with the fldSimple form R7 and Word both understand.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | Which part (default header). | |
| text | No | New text for the part. | |
| type | No | Which of the three header/footer kinds (default default). | |
| action | No | list (default) reports every header/footer part; read returns one part; setText changes its text; create makes it when missing; addPageNumber adds a PAGE field; remove deletes the part. | |
| filePath | Yes | Path to the DOCX file. | |
| position | No | Where to put the field inside the paragraph (default end). | |
| alignment | No | Alignment for a newly created part. | |
| separator | No | Literal text placed before the field, e.g. "Page ". | |
| outputPath | No | Write to a copy instead of editing in place. | |
| pageNumber | No | Add a page-number field: true for PAGE, or a field instruction such as "NUMPAGES" or "PAGE of NUMPAGES". | |
| sectionIndex | No | Section that owns the part (0-based, default 0). | |
| paragraphIndex | No | Which paragraph of the part to re-text (default 0). |