Master Page
Classes related to “style:master-page”.
Classes:
| Name | Description |
|---|---|
StyleFooter |
Content of a footer in a StyleMasterPage, tag “style:footer”. |
StyleFooterFirst |
Content of a footer for a first page, if different from the left/right |
StyleFooterLeft |
Content of a left page footer in a StyleMasterPage, tag “style:footer- |
StyleHeader |
Content of a header in a StyleMasterPage, tag “style:header”. |
StyleHeaderFirst |
Content of a header for a first page, if different from the left/right |
StyleHeaderLeft |
Content of a left page header in a StyleMasterPage, tag “style:header- |
StyleMasterPage |
Container of headers and footers, “style:master-page”. |
StyleFooter
Bases: StyleHeader
Content of a footer in a StyleMasterPage, tag “style:footer”.
The “style:display” attribute specifies whether the footer is displayed or not (“true” or “false”). The default value is “true”.
Source code in odfdo/master_page.py
331 332 333 334 335 336 337 338 | |
_tag
class-attribute
instance-attribute
_tag: str = 'style:footer'
StyleFooterFirst
Bases: StyleHeader
Content of a footer for a first page, if different from the left/right page in a “style:master-page” element, tag “style:footer-first”.
The term “first page” means the first page to which the page style is applied, regardless of any numbering. If a different page style is applied in between two applications of the page style, that has the “style:footer-first” element, each of the applications of the page style has its own first page.
New in ODFv1.3.
Source code in odfdo/master_page.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
_tag
class-attribute
instance-attribute
_tag: str = 'style:footer-first'
StyleFooterLeft
Bases: StyleHeader
Content of a left page footer in a StyleMasterPage, tag “style:footer- left”.
If left page different from the right page in a “style:master-page”.
The “style:display” attribute specifies whether the footer is displayed or not (“true” or “false”). The default value is “true”.
Source code in odfdo/master_page.py
373 374 375 376 377 378 379 380 381 382 383 | |
_tag
class-attribute
instance-attribute
_tag: str = 'style:footer-left'
StyleHeader
Bases: ListMixin, TocMixin, UserFieldDeclContMixin, VarDeclMixin, TrackedChangesMixin, SectionMixin, StyleBase
Content of a header in a StyleMasterPage, tag “style:header”.
The “style:display” attribute specifies whether the header is displayed or not (“true” or “false”). The default value is “true”.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a StyleHeader element. |
__repr__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
display |
bool
|
Get the display status of the header. |
Source code in odfdo/master_page.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
_tag
class-attribute
instance-attribute
_tag: str = 'style:header'
display
property
writable
display: bool
Get the display status of the header.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the header is displayed, False otherwise. |
__init__
__init__(
display: str | bool | None = True, **kwargs: Any
) -> None
Initialize a StyleHeader element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display
|
str | bool | None
|
Specifies whether the header is displayed. Can be “true”, “false”, or a boolean. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the parent |
{}
|
Source code in odfdo/master_page.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
__repr__
__repr__() -> str
Source code in odfdo/master_page.py
327 328 | |
StyleHeaderFirst
Bases: StyleHeader
Content of a header for a first page, if different from the left/right page in a “style:master-page” element, tag “style:header-first”
The term “first page” means the first page to which the page style is applied, regardless of any numbering. If a different page style is applied in between two applications of a page style that has the “style:header-first” element, each of the applications of the page style has its own first page.
The “style:display” attribute specifies whether the header is displayed or not (“true” or “false”). The default value is “true”.
New in ODFv1.3.
Source code in odfdo/master_page.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
_tag
class-attribute
instance-attribute
_tag: str = 'style:header-first'
StyleHeaderLeft
Bases: StyleHeader
Content of a left page header in a StyleMasterPage, tag “style:header- left”.
If left page different from the right page in a “style:master-page”.
The “style:display” attribute specifies whether the header is displayed or not (“true” or “false”). The default value is “true”.
Source code in odfdo/master_page.py
341 342 343 344 345 346 347 348 349 350 351 | |
_tag
class-attribute
instance-attribute
_tag: str = 'style:header-left'
StyleMasterPage
Bases: OfficeFormsMixin, StyleBase
Container of headers and footers, “style:master-page”.
In text and spreadsheet documents, the “style:master-page” element contains the content of headers and footers. For these types of documents, consumers may generate a sequence of pages by making use of a single master page or a set of master pages.
In drawing and presentation documents, the “style:master-page” element is used to define master pages as common backgrounds for drawing pages. Each drawing page is directly linked to one master page, which is specified by the draw:master-page-name attribute of the drawing pages style.
Master pages are contained in the “office:master-styles” element.
All documents shall contain at least one master page element.
If a text or spreadsheet document is displayed in a paged layout, master pages are used to generate a sequence of pages containing the document content. When a page is created, an empty page is generated with the properties of the master page and the static content of the master page. The body of the page is then filled with content. A single master pages can be used to created multiple pages within a document.
In text and spreadsheet documents, a master page can be assigned to paragraph and table styles using a style:master-page-name attribute. Each time the paragraph or table style is applied to text, a page break is inserted before the paragraph or table. A page that starts at the page break position uses the specified master page.
In drawings and presentations, master pages can be assigned to drawing pages using a style:parent-style-name attribute.
The “style:master-page” element is usable within the following element: “office:master-styles”.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a StyleMasterPage. |
__repr__ |
|
get_page_footer |
Get the |
get_page_header |
Get the |
set_font |
This method is not applicable to |
set_page_footer |
Set or replace the content of the page footer. |
set_page_header |
Set or replace the content of the page header. |
Attributes:
| Name | Type | Description |
|---|---|---|
display_name |
|
|
draw_style_name |
|
|
family |
str | None
|
Get the family of the style. |
name |
|
|
next_style |
|
|
page_layout |
|
Source code in odfdo/master_page.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
_family
instance-attribute
_family = 'master-page'
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = (
PropDef("name", "style:name"),
PropDef("display_name", "style:display-name"),
PropDef(
"page_layout",
"style:page-layout-name",
"master-page",
),
PropDef(
"next_style", "style:next-style-name", "master-page"
),
PropDef("draw_style_name", "draw:style-name"),
)
_tag
class-attribute
instance-attribute
_tag: str = 'style:master-page'
display_name
instance-attribute
display_name = display_name
draw_style_name
instance-attribute
draw_style_name = draw_style_name
family
property
writable
family: str | None
Get the family of the style.
For StyleMasterPage, this is always “master-page”.
name
instance-attribute
name = name
next_style
instance-attribute
next_style = next_style
page_layout
instance-attribute
page_layout = page_layout
__init__
__init__(
name: str | None = None,
display_name: str | None = None,
page_layout: str | None = None,
next_style: str | None = None,
draw_style_name: str | None = None,
**kwargs: Any,
) -> None
Initialize a StyleMasterPage.
The master page’s name is not mandatory at creation but becomes
required when inserted into a document as a common style.
The display_name is the name visible to the user in office applications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The internal name of the master page style. |
None
|
display_name
|
str | None
|
The user-facing display name of the style. |
None
|
page_layout
|
str | None
|
The name of the page layout style to use. |
None
|
next_style
|
str | None
|
The name of the next master page style to apply. |
None
|
draw_style_name
|
str | None
|
The name of the drawing style to apply. |
None
|
**kwargs
|
Any
|
Additional keyword arguments for the parent |
{}
|
Source code in odfdo/master_page.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
__repr__
__repr__() -> str
Source code in odfdo/master_page.py
150 151 | |
_set_header_or_footer
_set_header_or_footer(
text_or_element: str | Element | list[Element | str],
name: str = "header",
style: str = "Header",
) -> None
Internal helper to set the content of a page header or footer.
This method replaces existing content or creates a new header/footer
element if one doesn’t exist. It can accept raw text, an Element,
or a list of Elements or strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_or_element
|
str | Element | list[Element | str]
|
The content to set. Can be a string, an |
required |
name
|
str
|
The name of the part to set (“header” or “footer”). |
'header'
|
style
|
str
|
The default style name to apply to new paragraphs created from string content. |
'Header'
|
Source code in odfdo/master_page.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
get_page_footer
get_page_footer() -> Element | None
Get the style:footer element containing the footer contents.
Returns:
| Type | Description |
|---|---|
Element | None
|
Element | None: The |
Source code in odfdo/master_page.py
227 228 229 230 231 232 233 234 | |
get_page_header
get_page_header() -> Element | None
Get the style:header element containing the header contents.
Returns:
| Type | Description |
|---|---|
Element | None
|
Element | None: The |
Source code in odfdo/master_page.py
202 203 204 205 206 207 208 209 | |
set_font
set_font(
name: str,
family: str | None = None,
family_generic: str | None = None,
pitch: str = "variable",
) -> None
This method is not applicable to StyleMasterPage and does nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The font name. |
required |
family
|
str | None
|
The font family. If None, defaults to |
None
|
family_generic
|
str | None
|
The generic font family (e.g., ‘swiss’, ‘roman’). |
None
|
pitch
|
str
|
The font pitch (‘variable’ or ‘fixed’). Defaults to ‘variable’. |
'variable'
|
Source code in odfdo/master_page.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
set_page_footer
set_page_footer(
text_or_element: str | Element | list[Element | str],
) -> None
Set or replace the content of the page footer.
This method uses _set_header_or_footer to update the footer’s content.
You can provide raw text, an Element, or a list of content to replace
the existing footer. To modify the existing footer without replacing it
entirely, retrieve it first using get_page_footer and use its API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_or_element
|
str | Element | list[Element | str]
|
The new content for the footer. |
required |
Source code in odfdo/master_page.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
set_page_header
set_page_header(
text_or_element: str | Element | list[Element | str],
) -> None
Set or replace the content of the page header.
This method uses _set_header_or_footer to update the header’s content.
You can provide raw text, an Element, or a list of content to replace
the existing header. To modify the existing header without replacing it
entirely, retrieve it first using get_page_header and use its API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_or_element
|
str | Element | list[Element | str]
|
The new content for the header. |
required |
Source code in odfdo/master_page.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |