Repository navigation
word section set
goworm edited this page Jun 26, 2026
·
53 revisions
Modify section page layout, orientation, and margins.
Path: /section[N] or /body/sectPr[N] (canonical form returned by get/query; both accepted on set)
| Property | Accepted Values | Description |
|---|---|---|
type |
continuous, evenPage/even, oddPage/odd, nextPage/next
|
Break type. Invalid values throw an error. |
pageWidth |
twips or units (cm, in, pt) |
Width (e.g., 21cm, 8.5in) |
pageHeight |
twips or units (cm, in, pt) |
Height (e.g., 29.7cm, 11in) |
orientation |
landscape, portrait
|
Orientation. Setting landscape auto-swaps width/height if misaligned. |
marginTop/Bottom/Left/Right |
twips | Margins |
marginHeader |
twips or units | Header-from-top-edge distance (pgMar @header) |
marginFooter |
twips or units | Footer-from-bottom-edge distance (pgMar @footer) |
marginGutter |
twips or units | Binding gutter width (pgMar @gutter) |
columns/cols/col
|
"3" or "3,720"
|
Column count, or count with space (twips) |
colWidths |
alternating values | Custom column widths: "width,space,width,space,..." (twips) |
separator/sep
|
bool | Line between columns |
pageNumFmt |
full ECMA-376 enum | Page-number numbering format. Accepts decimal, upperRoman, lowerRoman, upperLetter, lowerLetter, plus locale-aware values: hindiNumbers, hindiVowels, arabicAlpha, arabicAbjad, thaiLetters/thaiNumbers/thaiCounting, bahtText/dollarText, hebrew1/hebrew2, iroha, aiueo, ganada, chosung, chineseCounting/chineseLegalSimplified, japaneseCounting/japaneseDigitalTenThousand/japaneseLegal, koreanCounting/koreanLegal, decimalEnclosedCircle/Fullstop/Paren, decimalFullWidth/HalfWidth/Zero, vietnameseCounting, russianLower/russianUpper, etc. See i18n for the full list. |
direction / dir
|
rtl / ltr
|
Section reading direction (<w:bidi/> on sectPr) |
pageStart |
integer | Restart page numbering at the given value |
titlePage / titlePg
|
bool | Different first-page header/footer |
break |
newPage/page (alias for nextPage) |
Section break alias |
headerRef.default / headerRef.first / headerRef.even
|
rId (read-only) | Header reference targets surfaced on Get |
footerRef.default / footerRef.first / footerRef.even
|
rId (read-only) | Footer reference targets surfaced on Get |
rtlGutter |
bool | RTL binding-gutter flag (<w:rtlGutter/>); ranks between bidi and docGrid in canonical schema order |
pgBorders / pageBorders
|
box, none
|
Page-border shorthand. box emits a 4pt solid border on top/left/bottom/right in CT_PageBorders schema order; none strips the element |
pgBorders.top / .left / .bottom / .right
|
STYLE[;SIZE[;COLOR[;SPACE]]] |
Per-side page border (SIZE in eighths-of-pt or unit-qualified length; SPACE in points-from-edge twips). Mirrors paragraph pbdr.* / table border.* value form. Get surfaces STYLE on the key and SIZE/COLOR/SPACE on .sz/.color/.space sub-keys |
pgBorders.offsetFrom |
page, text
|
Whether the border is measured from the page edge (page) or the text margin (text, OOXML default) |
pgBorders.zOrder |
front, back
|
Whether the page border is drawn in front of (front, default) or behind (back) the page text |
pgBorders.display |
allPages, firstPage, notFirstPage
|
Which pages of the section the page border appears on |
paperSrc.first |
integer (0-65535) | Printer paper-source bin for the first page (<w:paperSrc w:first>) |
paperSrc.other |
integer (0-65535) | Printer paper-source bin for the remaining pages (<w:paperSrc w:other>) |
formProt |
bool | Section form-protection flag (<w:formProt>); locks content except form fields. Accepts none/off/false to clear |
lineNumbers |
continuous, restartPage/page, restartSection/section
|
Line numbering mode (<w:lnNumType>) |
lineNumberCountBy |
integer | Line numbering interval (every Nth line gets a number); only emitted when > 1 |
lineNumberDistance |
integer (twips) | Gutter spacing between the line-number column and body text (<w:lnNumType w:distance>) |
footnotePr.numFmt / .format
|
decimal, lowerRoman, upperRoman, lowerLetter, upperLetter, chicago
|
Section footnote number format (<w:footnotePr><w:numFmt>) |
footnotePr.numRestart / .restart
|
continuous, eachSect, eachPage
|
Section footnote numbering restart (<w:footnotePr><w:numRestart>) |
footnotePr.numStart |
integer | Section footnote starting number (<w:footnotePr><w:numStart>) |
footnotePr.pos / .position
|
pageBottom, beneath, sectEnd
|
Section footnote placement (<w:footnotePr><w:pos>) |
endnotePr.numFmt / .format
|
decimal, lowerRoman, upperRoman, lowerLetter, upperLetter, chicago
|
Section endnote number format (<w:endnotePr><w:numFmt>) |
endnotePr.numRestart / .restart
|
continuous, eachSect, eachPage
|
Section endnote numbering restart (<w:endnotePr><w:numRestart>) |
endnotePr.numStart |
integer | Section endnote starting number (<w:endnotePr><w:numStart>) |
endnotePr.pos / .position
|
sectEnd, docEnd
|
Section endnote placement (<w:endnotePr><w:pos>) |
Note: Get returns pageWidth and pageHeight as unit-qualified cm strings (e.g., "21cm", "29.7cm").
# Set landscape with twips
officecli set report.docx /section[2] --prop orientation=landscape --prop pageWidth=15840 --prop pageHeight=12240
# Set A4 with unit suffixes
officecli set report.docx /section[1] --prop pageWidth=21cm --prop pageHeight=29.7cm
# Set US Letter with inches
officecli set report.docx /section[1] --prop pageWidth=8.5in --prop pageHeight=11in
# Set 3 equal columns
officecli set report.docx /section[1] --prop columns=3
# Set 3 columns with custom spacing (720 twips)
officecli set report.docx /section[1] --prop cols="3,720"
# Set custom column widths with spacing
officecli set report.docx /section[1] --prop colWidths="3000,720,2000,720,3000"
# Add separator line between columns
officecli set report.docx /section[1] --prop columns=2 --prop separator=trueBased on OfficeCLI v1.0.66