Skip to content

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
class StyleFooter(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".
    """

    _tag: str = "style:footer"

_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
class StyleFooterFirst(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.
    """

    _tag: str = "style:footer-first"

_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
class StyleFooterLeft(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".
    """

    _tag: str = "style:footer-left"

_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
class StyleHeader(
    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".
    """

    _tag: str = "style:header"

    def __init__(
        self,
        display: str | bool | None = True,
        # Every other property
        **kwargs: Any,
    ) -> None:
        """Initialize a StyleHeader element.

        Args:
            display: Specifies whether the header is displayed.
                Can be "true", "false", or a boolean. Defaults to True.
            **kwargs: Additional keyword arguments for the parent `Element` class.
        """
        super().__init__(**kwargs)
        if self._do_init:
            kwargs.pop("tag", None)
            kwargs.pop("tag_or_elem", None)
            self.display = display

    @property
    def display(self) -> bool:
        """Get the display status of the header.

        Returns:
            bool: True if the header is displayed, False otherwise.
        """
        return self._get_attribute_bool_default("style:display", True)

    @display.setter
    def display(self, display: bool | str | None) -> None:
        """Set the display status of the header.

        Args:
            display: The display status. Can be a boolean,
                or "true"/"false" string.
        """
        self._set_attribute_bool_default("style:display", display, True)

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__}>"

_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 Element class.

{}
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
def __init__(
    self,
    display: str | bool | None = True,
    # Every other property
    **kwargs: Any,
) -> None:
    """Initialize a StyleHeader element.

    Args:
        display: Specifies whether the header is displayed.
            Can be "true", "false", or a boolean. Defaults to True.
        **kwargs: Additional keyword arguments for the parent `Element` class.
    """
    super().__init__(**kwargs)
    if self._do_init:
        kwargs.pop("tag", None)
        kwargs.pop("tag_or_elem", None)
        self.display = display

__repr__

__repr__() -> str
Source code in odfdo/master_page.py
327
328
def __repr__(self) -> str:
    return f"<{self.__class__.__name__}>"

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
class StyleHeaderFirst(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.
    """

    _tag: str = "style:header-first"

_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
class StyleHeaderLeft(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".
    """

    _tag: str = "style:header-left"

_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 style:footer element containing the footer contents.

get_page_header

Get the style:header element containing the header contents.

set_font

This method is not applicable to StyleMasterPage and does nothing.

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
class StyleMasterPage(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".
    """

    # The <style:master-page> element has the following attributes:
    # draw:style-name
    # style:display-name
    # style:name
    # style:next-style-name
    # style:page-layout-name

    _tag: str = "style:master-page"
    _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"),
    )

    def __init__(
        self,
        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.

        Args:
            name: The internal name of the master page style.
            display_name: The user-facing display name of the style.
            page_layout: The name of the page layout style to use.
            next_style: The name of the next master page style to apply.
            draw_style_name: The name of the drawing style to apply.
            **kwargs: Additional keyword arguments for the parent `Element` class.
        """
        self._family = "master-page"
        tag_or_elem = kwargs.get("tag_or_elem")
        if tag_or_elem is None:
            kwargs["tag"] = "style:master-page"
        Element.__init__(self, **kwargs)
        if self._do_init:
            # print("_do_init")
            kwargs.pop("tag", None)
            kwargs.pop("tag_or_elem", None)
            if name:
                self.name = name
            if display_name:
                self.display_name = display_name
            if page_layout:
                self.page_layout = page_layout
            if next_style:
                self.next_style = next_style
            if draw_style_name:
                self.draw_style_name = draw_style_name

    @property
    def family(self) -> str | None:
        """Get the family of the style.

        For `StyleMasterPage`, this is always "master-page".
        """
        return self._family

    @family.setter
    def family(self, family: str | None) -> None:
        """Setter for the family property (no-op as family is fixed)."""
        pass

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__} family={self.family} name={self.name}>"

    def _set_header_or_footer(
        self,
        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 `Element`s or strings.

        Args:
            text_or_element: The content to set. Can be a string, an `Element`,
                or an iterable of strings and/or `Element`s.
            name: The name of the part to set ("header" or "footer").
            style: The default style name to apply to new paragraphs
                created from string content.
        """
        if name == "header":
            header_or_footer = self.get_page_header()
        else:
            header_or_footer = self.get_page_footer()
        if header_or_footer is None:
            header_or_footer = Element.from_tag("style:" + name)
            self.append(header_or_footer)
        else:
            header_or_footer.clear()
        if (
            isinstance(text_or_element, Element)
            and text_or_element.tag == f"style:{name}"
        ):
            # Already a header or footer?
            self.delete(header_or_footer)
            self.append(text_or_element)
            return
        if isinstance(text_or_element, (Element, str)):
            elem_list: list[Element | str] = [text_or_element]
        else:
            elem_list = text_or_element
        for item in elem_list:
            if isinstance(item, str):
                paragraph = Element.from_tag("text:p")
                paragraph.append_plain_text(item)  # type: ignore
                paragraph.style = style  # type: ignore
                header_or_footer.append(paragraph)
            elif isinstance(item, Element):
                header_or_footer.append(item)

    def get_page_header(self) -> Element | None:
        """Get the `style:header` element containing the header contents.

        Returns:
            Element | None: The `style:header` element, or `None` if no header
                content is defined for this master page.
        """
        return self.get_element("style:header")

    def set_page_header(
        self,
        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.

        Args:
            text_or_element: The new content for the header.
        """
        self._set_header_or_footer(text_or_element)

    def get_page_footer(self) -> Element | None:
        """Get the `style:footer` element containing the footer contents.

        Returns:
            Element | None: The `style:footer` element, or `None` if no footer
                content is defined for this master page.
        """
        return self.get_element("style:footer")

    def set_page_footer(
        self,
        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.

        Args:
            text_or_element: The new content for the footer.
        """
        self._set_header_or_footer(text_or_element, name="footer", style="Footer")

    def set_font(
        self,
        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.

        Args:
            name: The font name.
            family: The font family. If None, defaults to `name`.
            family_generic: The generic font family (e.g., 'swiss', 'roman').
            pitch: The font pitch ('variable' or 'fixed'). Defaults to 'variable'.
        """

_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 Element class.

{}
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
def __init__(
    self,
    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.

    Args:
        name: The internal name of the master page style.
        display_name: The user-facing display name of the style.
        page_layout: The name of the page layout style to use.
        next_style: The name of the next master page style to apply.
        draw_style_name: The name of the drawing style to apply.
        **kwargs: Additional keyword arguments for the parent `Element` class.
    """
    self._family = "master-page"
    tag_or_elem = kwargs.get("tag_or_elem")
    if tag_or_elem is None:
        kwargs["tag"] = "style:master-page"
    Element.__init__(self, **kwargs)
    if self._do_init:
        # print("_do_init")
        kwargs.pop("tag", None)
        kwargs.pop("tag_or_elem", None)
        if name:
            self.name = name
        if display_name:
            self.display_name = display_name
        if page_layout:
            self.page_layout = page_layout
        if next_style:
            self.next_style = next_style
        if draw_style_name:
            self.draw_style_name = draw_style_name

__repr__

__repr__() -> str
Source code in odfdo/master_page.py
150
151
def __repr__(self) -> str:
    return f"<{self.__class__.__name__} family={self.family} name={self.name}>"
_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 Element, or an iterable of strings and/or Elements.

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
def _set_header_or_footer(
    self,
    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 `Element`s or strings.

    Args:
        text_or_element: The content to set. Can be a string, an `Element`,
            or an iterable of strings and/or `Element`s.
        name: The name of the part to set ("header" or "footer").
        style: The default style name to apply to new paragraphs
            created from string content.
    """
    if name == "header":
        header_or_footer = self.get_page_header()
    else:
        header_or_footer = self.get_page_footer()
    if header_or_footer is None:
        header_or_footer = Element.from_tag("style:" + name)
        self.append(header_or_footer)
    else:
        header_or_footer.clear()
    if (
        isinstance(text_or_element, Element)
        and text_or_element.tag == f"style:{name}"
    ):
        # Already a header or footer?
        self.delete(header_or_footer)
        self.append(text_or_element)
        return
    if isinstance(text_or_element, (Element, str)):
        elem_list: list[Element | str] = [text_or_element]
    else:
        elem_list = text_or_element
    for item in elem_list:
        if isinstance(item, str):
            paragraph = Element.from_tag("text:p")
            paragraph.append_plain_text(item)  # type: ignore
            paragraph.style = style  # type: ignore
            header_or_footer.append(paragraph)
        elif isinstance(item, Element):
            header_or_footer.append(item)
get_page_footer() -> Element | None

Get the style:footer element containing the footer contents.

Returns:

Type Description
Element | None

Element | None: The style:footer element, or None if no footer content is defined for this master page.

Source code in odfdo/master_page.py
227
228
229
230
231
232
233
234
def get_page_footer(self) -> Element | None:
    """Get the `style:footer` element containing the footer contents.

    Returns:
        Element | None: The `style:footer` element, or `None` if no footer
            content is defined for this master page.
    """
    return self.get_element("style:footer")

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 style:header element, or None if no header content is defined for this master page.

Source code in odfdo/master_page.py
202
203
204
205
206
207
208
209
def get_page_header(self) -> Element | None:
    """Get the `style:header` element containing the header contents.

    Returns:
        Element | None: The `style:header` element, or `None` if no header
            content is defined for this master page.
    """
    return self.get_element("style:header")

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 name.

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
def set_font(
    self,
    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.

    Args:
        name: The font name.
        family: The font family. If None, defaults to `name`.
        family_generic: The generic font family (e.g., 'swiss', 'roman').
        pitch: The font pitch ('variable' or 'fixed'). Defaults to 'variable'.
    """
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
def set_page_footer(
    self,
    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.

    Args:
        text_or_element: The new content for the footer.
    """
    self._set_header_or_footer(text_or_element, name="footer", style="Footer")

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
def set_page_header(
    self,
    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.

    Args:
        text_or_element: The new content for the header.
    """
    self._set_header_or_footer(text_or_element)