docx
    Preparing search index...

    Class Theme

    Represents the theme of a document, written to word/theme/theme1.xml.

    Every document has one: Office's theme, from Office 2016 to 2021, with the colors and fonts the options give.

    Reference: http://officeopenxml.com/drwTheme.php

    <xsd:element name="theme" type="CT_OfficeStyleSheet"/>

    <xsd:complexType name="CT_OfficeStyleSheet">
    <xsd:sequence>
    <xsd:element name="themeElements" type="CT_BaseStyles" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="objectDefaults" type="CT_ObjectStyleDefaults" minOccurs="0" maxOccurs="1"/>
    <xsd:element name="extraClrSchemeLst" type="CT_ColorSchemeList" minOccurs="0" maxOccurs="1"/>
    <xsd:element name="custClrLst" type="CT_CustomColorList" minOccurs="0" maxOccurs="1"/>
    <xsd:element name="extLst" type="CT_OfficeArtExtensionList" minOccurs="0" maxOccurs="1"/>
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="optional" default=""/>
    </xsd:complexType>

    <xsd:complexType name="CT_BaseStyles">
    <xsd:sequence>
    <xsd:element name="clrScheme" type="CT_ColorScheme" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="fontScheme" type="CT_FontScheme" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="fmtScheme" type="CT_StyleMatrix" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="extLst" type="CT_OfficeArtExtensionList" minOccurs="0" maxOccurs="1"/>
    </xsd:sequence>
    </xsd:complexType>
    // A document whose theme has a green accent and Georgia for headings
    const doc = new Document({
    theme: { colors: { accent1: "2E7D32" }, fonts: { headings: "Georgia" } },
    sections: [],
    });

    Hierarchy (View Summary)

    Index
    • get writtenAs(): readonly BaseXmlComponent[] | undefined
      Internal

      The components written in this one's place, one after another, when it can't be written as a single element, such as a run with another run in its children. Undefined when it is written as itself.

      Returns readonly BaseXmlComponent[] | undefined

    • Prepares this component and its children for XML serialization.

      This method is called by the Formatter to convert the component tree into an object structure compatible with the xml library (https://www.npmjs.com/package/xml). It recursively processes all children and handles special cases like attribute-only elements and empty elements.

      The method can be overridden by subclasses to customize XML representation or execute side effects during serialization (e.g., creating relationships).

      Parameters

      • context: IContext

        The serialization context containing document state

      Returns IXmlableObject | undefined

      The XML-serializable object, or undefined to exclude from output

      // Override to add custom serialization logic
      prepForXml(context: IContext): IXmlableObject | undefined {
      // Custom logic here
      return super.prepForXml(context);
      }