ParagraphProperties Class

Paragraph Properties.When the object is serialized out as xml, its qualified name is w:pPr.


Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

public class ParagraphProperties : OpenXmlCompositeElement

The following table lists the possible child types:

[ISO/IEC 29500-1 1st Edition] pPr (Paragraph Properties)

This element specifies a set of paragraph properties which shall be applied to the contents of the parent paragraph after all style/numbering/table properties have been applied to the text. These properties are defined as direct formatting, since they are directly applied to the paragraph and supersede any formatting from styles.

[Example: Consider a paragraph which should have a set of paragraph formatting properties. This set of properties is specified in the paragraph properties as follows:

      <w:bottom w:val="single" w:sz="8" w:space="4" w:color="4F81BD" /> 
    <w:spacing w:after="300" /> 
    <w:contextualSpacing /> 

The pPr element specifies the properties which are applied to the current paragraph - in this case, a bottom paragraph border using the bottom element (§, spacing after the paragraph using the spacing element (§, and that spacing should be ignored for paragraphs above/below of the same style using the contextualSpacing element (§ end example]

Parent Elements

p (§

Child Elements


adjustRightInd (Automatically Adjust Right Indent When Using Document Grid)


autoSpaceDE (Automatically Adjust Spacing of Latin and East Asian Text)


autoSpaceDN (Automatically Adjust Spacing of East Asian Text and Numbers)


bidi (Right to Left Paragraph Layout)


cnfStyle (Paragraph Conditional Formatting)


contextualSpacing (Ignore Spacing Above and Below When Using Identical Styles)


divId (Associated HTML div ID)


framePr (Text Frame Properties)


ind (Paragraph Indentation)


jc (Paragraph Alignment)


keepLines (Keep All Lines On One Page)


keepNext (Keep Paragraph With Next Paragraph)


kinsoku (Use East Asian Typography Rules for First and Last Character per Line)


mirrorIndents (Use Left/Right Indents as Inside/Outside Indents)


numPr (Numbering Definition Instance Reference)


outlineLvl (Associated Outline Level)


overflowPunct (Allow Punctuation to Extend Past Text Extents)


pageBreakBefore (Start Paragraph on Next Page)


pBdr (Paragraph Borders)


pPrChange (Revision Information for Paragraph Properties)


pStyle (Referenced Paragraph Style)


rPr (Run Properties for the Paragraph Mark)


sectPr (Section Properties)


shd (Paragraph Shading)


snapToGrid (Use Document Grid Settings for Inter-Line Paragraph Spacing)


spacing (Spacing Between Lines and Above/Below Paragraph)


suppressAutoHyphens (Suppress Hyphenation for Paragraph)


suppressLineNumbers (Suppress Line Numbers for Paragraph)


suppressOverlap (Prevent Text Frames From Overlapping)


tabs (Set of Custom Tab Stops)


textAlignment (Vertical Character Alignment on Line)


textboxTightWrap (Allow Surrounding Paragraphs to Tight Wrap to Text Box Contents)


textDirection (Paragraph Text Flow Direction)


topLinePunct (Compress Punctuation at Start of a Line)


widowControl (Allow First/Last Line to Display on a Separate Page)


wordWrap (Allow Line Breaking At Character Level)


[Note: The W3C XML Schema definition of this element’s content model (CT_PPr) is located in §A.1. end note]

  • ParagraphStyleId <w:pStyle>

  • KeepNext <w:keepNext>

  • KeepLines <w:keepLines>

  • PageBreakBefore <w:pageBreakBefore>

  • FrameProperties <w:framePr>

  • WidowControl <w:widowControl>

  • NumberingProperties <w:numPr>

  • SuppressLineNumbers <w:suppressLineNumbers>

  • ParagraphBorders <w:pBdr>

  • Shading <w:shd>

  • Tabs <w:tabs>

  • SuppressAutoHyphens <w:suppressAutoHyphens>

  • Kinsoku <w:kinsoku>

  • WordWrap <w:wordWrap>

  • OverflowPunctuation <w:overflowPunct>

  • TopLinePunctuation <w:topLinePunct>

  • AutoSpaceDE <w:autoSpaceDE>

  • AutoSpaceDN <w:autoSpaceDN>

  • BiDi <w:bidi>

  • AdjustRightIndent <w:adjustRightInd>

  • SnapToGrid <w:snapToGrid>

  • SpacingBetweenLines <w:spacing>

  • Indentation <w:ind>

  • ContextualSpacing <w:contextualSpacing>

  • MirrorIndents <w:mirrorIndents>

  • SuppressOverlap <w:suppressOverlap>

  • Justification <w:jc>

  • TextDirection <w:textDirection>

  • TextAlignment <w:textAlignment>

  • TextBoxTightWrap <w:textboxTightWrap>

  • OutlineLevel <w:outlineLvl>

  • DivId <w:divId>

  • ConditionalFormatStyle <w:cnfStyle>

  • ParagraphMarkRunProperties <w:rPr>

  • SectionProperties <w:sectPr>

  • ParagraphPropertiesChange <w:pPrChange>

© ISO/IEC29500: 2008.

The following example opens an existing word processing document, searches it for a Heading1 styled paragraph, and inserts an outline descendant before that paragraph.

using System;
using System.Collections.Generic;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;

namespace ParagraphPropertiesEx
    class Program
        // Search all paragraphs of the specified style and make an outline descendant.
        static void Main(string[] args)
            string fileName = @"C:\Users\Public\Documents\ParagraphPropertiesEx.docx";
            using (WordprocessingDocument wordprocessingDocument = 
                WordprocessingDocument.Open(fileName, true))
                // Get the body element.
                var body = wordprocessingDocument.MainDocumentPart.Document.Body;

                //Define a list to store outline Paragraphs
                var paragraphs = new List<Paragraph>();

                // Search all Paragraphs that is "Heading1" style.
                foreach (Paragraph para in body.Descendants<Paragraph>().
                    Where(e => e.ParagraphProperties != null
                        && e.ParagraphProperties.ParagraphStyleId != null
                        && e.ParagraphProperties.ParagraphStyleId.Val == "Heading1"))
                    paragraphs.Add(new Paragraph(new Run(new Text(para.InnerText))));

                // Need to find whether first child is null, if so, add the paragragh collections to Body.
                if (body.FirstChild == null)

                // Else, get first child and always insert before it.
                    OpenXmlElement first = body.FirstChild;
                    foreach (Paragraph p in paragraphs)
            Console.WriteLine("All done. Press a key");

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions