docx
    Preparing search index...

    Class ParagraphProperties

    Represents paragraph properties (pPr) in a WordprocessingML document.

    The paragraph properties element specifies all formatting applied to a paragraph, including alignment, spacing, indentation, borders, numbering, and style references.

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

    <xsd:complexType name="CT_PPr">
    <xsd:complexContent>
    <xsd:extension base="CT_PPrBase">
    <xsd:sequence>
    <xsd:element name="rPr" type="CT_ParaRPr" minOccurs="0"/>
    <xsd:element name="sectPr" type="CT_SectPr" minOccurs="0"/>
    <xsd:element name="pPrChange" type="CT_PPrChange" minOccurs="0"/>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    The base type CT_PPrBase contains:

    <xsd:complexType name="CT_PPrBase">
    <xsd:sequence>
    <xsd:element name="pStyle" type="CT_String" minOccurs="0"/>
    <xsd:element name="keepNext" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="keepLines" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="pageBreakBefore" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="framePr" type="CT_FramePr" minOccurs="0"/>
    <xsd:element name="widowControl" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="numPr" type="CT_NumPr" minOccurs="0"/>
    <xsd:element name="suppressLineNumbers" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="pBdr" type="CT_PBdr" minOccurs="0"/>
    <xsd:element name="shd" type="CT_Shd" minOccurs="0"/>
    <xsd:element name="tabs" type="CT_Tabs" minOccurs="0"/>
    <xsd:element name="suppressAutoHyphens" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="kinsoku" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="wordWrap" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="overflowPunct" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="topLinePunct" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="autoSpaceDE" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="autoSpaceDN" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="bidi" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="adjustRightInd" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="snapToGrid" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="spacing" type="CT_Spacing" minOccurs="0"/>
    <xsd:element name="ind" type="CT_Ind" minOccurs="0"/>
    <xsd:element name="contextualSpacing" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="mirrorIndents" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="suppressOverlap" type="CT_OnOff" minOccurs="0"/>
    <xsd:element name="jc" type="CT_Jc" minOccurs="0"/>
    <xsd:element name="textDirection" type="CT_TextDirection" minOccurs="0"/>
    <xsd:element name="textAlignment" type="CT_TextAlignment" minOccurs="0"/>
    <xsd:element name="textboxTightWrap" type="CT_TextboxTightWrap" minOccurs="0"/>
    <xsd:element name="outlineLvl" type="CT_DecimalNumber" minOccurs="0"/>
    <xsd:element name="divId" type="CT_DecimalNumber" minOccurs="0"/>
    <xsd:element name="cnfStyle" type="CT_Cnf" minOccurs="0" maxOccurs="1"/>
    </xsd:sequence>
    </xsd:complexType>
    // Basic paragraph with alignment
    new ParagraphProperties({
    alignment: AlignmentType.CENTER,
    });

    // Formatted paragraph with spacing and indentation
    new ParagraphProperties({
    alignment: AlignmentType.JUSTIFIED,
    spacing: { before: 200, after: 200, line: 360 },
    indent: { left: 720, right: 720 },
    });

    // Heading with outline level
    new ParagraphProperties({
    heading: HeadingLevel.HEADING_1,
    outlineLevel: 0,
    keepNext: true,
    });

    // Numbered list item
    new ParagraphProperties({
    numbering: {
    reference: "my-numbering",
    level: 0,
    instance: 0,
    },
    });

    // Paragraph with borders and shading
    new ParagraphProperties({
    border: {
    top: { style: BorderStyle.SINGLE, size: 6, color: "000000" },
    bottom: { style: BorderStyle.SINGLE, size: 6, color: "000000" },
    },
    shading: { fill: "EEEEEE" },
    });

    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

    • Adds the section properties (w:sectPr) of the section this paragraph ends.

      They go after the paragraph's run properties and before its revision (w:pPrChange), the order CT_PPr gives them.

      Parameters

      • sectionProperties: SectionProperties

        The properties of the section the paragraph ends

      Returns void

    • Prepares the paragraph properties for XML serialization.

      This method works out which list instance a numbered paragraph is in, from where it is in its part when it leaves out instance, and creates the concrete numbering instance for it before the properties are converted to XML.

      Parameters

      • context: IContext

        The XML context containing document and file information

      Returns IXmlableObject | undefined

      The prepared XML object, or undefined if the component should be ignored