layout_apply
Apply a page plan to a .docx: set section starts, breaks, page numbering, headers/footers, and two-sided or mirrored margins, with all-or-nothing validation and optional dry-run preview.
Instructions
Bring the document to a page plan (as layout.get returns it): where each section starts (from), its break (nextPage, oddPage for a right-hand start, evenPage, continuous), the page-number start and format, a different first page, the header and footer text per kind (default, first, even; {PAGE}, {NUMPAGES} and {chapter} become fields; null drops the section's own, so it inherits the previous section's; asking the text a section already prints changes nothing; a new part or a dropped reference that would change what a later section inheriting it prints is refused, as changing a header or footer that later sections inherit is not supported yet), two_sided (even and odd headers) and mirror_margins. Keys left out stay as they are; shown is checked, not set. Breaks, numbering and the text of a header or footer part are tracked changes; a part is rewritten only when every section using it asks the same text, else the section gets a new part. A new part, a dropped reference and two_sided or mirror_margins cannot be tracked and need untracked: true (LAYOUT D-L2). Sections already in the document must all be kept. A section that still holds an unaccepted tracked change of its setup (say from an earlier layout.apply) cannot take another, so a second apply that changes it is refused (UNSUPPORTED_CONTENT) until that change is accepted or rejected. A split-off section keeps the number format of the section it came from unless the plan states one. All or nothing: the plan read back from the result must equal the request, else nothing is written (UNSUPPORTED_CONTENT). dry_run lists the changes and the plan that would result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc | Yes | Path to the .docx. | |
| tag | No | Appended to the author. | |
| plan | Yes | The page plan: version 1 and sections, each with a from address. | |
| author | No | Revision author. | |
| expect | No | ||
| dry_run | No | Preview only; write nothing. | |
| untracked | No | Allow a change Word cannot track (LAYOUT D-L2). |