Get Started
Usage API
More information

ApiParagraph

new ApiParagraph()

Class representing a paragraph.

Methods

Name Description
AddBookmarkCrossRef

Adds a bookmark cross-reference to the current paragraph. The paragraph must be in the document.

AddCaptionCrossRef

Adds a caption cross-reference to the current paragraph. The paragraph must be in the document.

AddColumnBreak

Adds a column break to the current position and starts the next element from a new column.

AddComment

Adds a comment to the paragraph.

AddDrawing

Adds a drawing object (image, shape or chart) to the current paragraph.

AddElement

Adds an element to the current paragraph.

AddEndnoteCrossRef

Adds an endnote cross-reference to the current paragraph. The paragraph must be in the document.

AddFootnoteCrossRef

Adds a footnote cross-reference to the current paragraph. The paragraph must be in the document.

AddHeadingCrossRef

Adds a heading cross-reference to the current paragraph. The paragraph must be in the document.

AddHyperlink

Adds a hyperlink to a paragraph.

AddInlineLvlSdt

Adds an inline container.

AddLineBreak

Adds a line break to the current position and starts the next element from a new line.

AddNumberedCrossRef

Adds a numbered cross-reference to the current paragraph. The paragraph must be in the document.

AddPageBreak

Adds a page break and starts the next element from the next page.

AddPageNumber

Inserts a number of the current document page into the paragraph. This method works for the paragraphs in the document header/footer only.

AddPagesCount

Inserts a number of pages in the current document into the paragraph. This method works for the paragraphs in the document header/footer only.

AddTabStop

Adds a tab stop to the current paragraph.

AddText

Adds some text to the current paragraph.

Copy

Creates a paragraph copy. Ingnore comments, footnote references, complex fields.

Delete

Deletes the current paragraph.

GetAllCharts

Returns a collection of chart objects in the paragraph.

GetAllContentControls

Returns a collection of content control objects in the paragraph.

GetAllDrawingObjects

Returns a collection of drawing objects in the paragraph.

GetAllImages

Returns a collection of image objects in the paragraph.

GetAllShapes

Returns a collection of shape objects in the paragraph.

GetClassType

Returns a type of the ApiParagraph class.

GetElement

Returns a paragraph element using the position specified.

GetElementsCount

Returns a number of elements in the current paragraph.

GetIndFirstLine

Returns the paragraph first line indentation.

GetIndLeft

Returns the paragraph left side indentation.

GetIndRight

Returns the paragraph right side indentation.

GetJc

Returns the paragraph contents justification.

GetLastRunWithText

Returns the last Run with text in the current paragraph.

GetNext

Returns the next paragraph.

GetNumbering

Returns the numbering definition and numbering level for the numbered list.

GetParagraphMarkTextPr

Returns the text properties of the paragraph mark which is used to mark the paragraph end. The mark can also acquire common text properties like bold, italic, underline, etc.

GetParaPr

Returns the paragraph properties.

GetParentContentControl

Returns a content control that contains the current paragraph.

GetParentTable

Returns a table that contains the current paragraph.

GetParentTableCell

Returns a table cell that contains the current paragraph.

GetPrevious

Returns the previous paragraph.

GetRange

Returns a Range object that represents the part of the document contained in the specified paragraph.

GetShd

Returns the shading applied to the contents of the paragraph.

GetSpacingAfter

Returns the spacing after value of the current paragraph.

GetSpacingBefore

Returns the spacing before value of the current paragraph.

GetSpacingLineRule

Returns the paragraph line spacing rule.

GetSpacingLineValue

Returns the paragraph line spacing value.

GetStyle

Returns the paragraph style method.

GetText

Returns the paragraph text.

GetTextPr

Returns the paragraph text properties.

InsertInContentControl

Wraps the paragraph object with a rich text content control.

InsertParagraph

Inserts a paragraph at the specified position.

Last

Returns the last element of the paragraph which is not empty.

Push

Adds an element to the current paragraph.

RemoveAllElements

Removes all the elements from the current paragraph. When all the elements are removed from the paragraph, a new empty run is automatically created. If you want to add content to this run, use the ApiParagraph.GetElement method.

RemoveElement

Removes an element using the position specified. If the element you remove is the last paragraph element (i.e. all the elements are removed from the paragraph), a new empty run is automatically created. If you want to add content to this run, use the ApiParagraph.GetElement method.

Search

Searches for a scope of a paragraph object. The search results are a collection of ApiRange objects.

Select

Selects the current paragraph.

SetBetweenBorder

Specifies the border which will be displayed between each paragraph in a set of paragraphs which have the same set of paragraph border settings.

SetBold

Sets the bold property to the text character.

SetBottomBorder

Specifies the border which will be displayed below a set of paragraphs which have the same paragraph border settings. The paragraphs of the same style going one by one are considered as a single block, so the border is added to the whole block rather than to every paragraph in this block.

SetBullet

Sets the bullet or numbering to the current paragraph.

SetCaps

Specifies that any lowercase characters in this paragraph are formatted for display only as their capital letter character equivalents.

SetColor

Sets the text color to the current paragraph in the RGB format.

SetContextualSpacing

Specifies that any space before or after this paragraph set using the ApiParaPr.SetSpacingBefore or ApiParaPr.SetSpacingAfter spacing element, should not be applied when the preceding and following paragraphs are of the same paragraph style, affecting the top and bottom spacing respectively.

SetDoubleStrikeout

Specifies that the contents of this paragraph are displayed with two horizontal lines through each character displayed on the line.

SetFontFamily

Sets all 4 font slots with the specified font family.

SetFontSize

Sets the font size to the characters of the current paragraph.

SetHighlight

Specifies a highlighting color which is applied as a background to the contents of the current paragraph.

SetIndFirstLine

Sets the paragraph first line indentation.

SetIndLeft

Sets the paragraph left side indentation.

SetIndRight

Sets the paragraph right side indentation.

SetItalic

Sets the italic property to the text character.

SetJc

Sets the paragraph contents justification.

SetKeepLines

Specifies that when rendering the document using a page view, all lines of the current paragraph are maintained on a single page whenever possible.

SetKeepNext

Specifies that when rendering the document using a paginated view, the contents of the current paragraph are at least partly rendered on the same page as the following paragraph whenever possible.

SetLeftBorder

Specifies the border which will be displayed at the left side of the page around the specified paragraph.

SetNumbering

Specifies that the current paragraph references the numbering definition instance in the current document.

SetNumPr

Specifies that the current paragraph references a numbering definition instance in the current document.

SetPageBreakBefore

Specifies that when rendering the document using a paginated view, the contents of the current paragraph are rendered at the beginning of a new page in the document.

SetPosition

Specifies an amount by which text is raised or lowered for this paragraph in relation to the default baseline of the surrounding non-positioned text.

SetRightBorder

Specifies the border which will be displayed at the right side of the page around the specified paragraph.

SetShd

Specifies the shading applied to the contents of the current paragraph.

SetSmallCaps

Specifies that all the small letter characters in this paragraph are formatted for display only as their capital letter character equivalents which are two points smaller than the actual font size specified for this text.

SetSpacing

Sets the text spacing measured in twentieths of a point.

SetSpacingAfter

Sets the spacing after the current paragraph. If the value of the isAfterAuto parameter is true, then any value of the nAfter is ignored. If isAfterAuto parameter is not specified, then it will be interpreted as false.

SetSpacingBefore

Sets the spacing before the current paragraph. If the value of the isBeforeAuto parameter is true, then any value of the nBefore is ignored. If isBeforeAuto parameter is not specified, then it will be interpreted as false.

SetSpacingLine

Sets the paragraph line spacing. If the value of the sLineRule parameter is either "atLeast" or "exact", then the value of nLine will be interpreted as twentieths of a point. If the value of the sLineRule parameter is "auto", then the value of the nLine parameter will be interpreted as 240ths of a line.

SetStrikeout

Specifies that the contents of this paragraph are displayed with a single horizontal line through the center of the line.

SetStyle

The paragraph style base method. This method is not used by itself, as it only forms the basis for the ApiParagraph.SetStyle method which sets the selected or created style for the paragraph.

SetTabs

Specifies a sequence of custom tab stops which will be used for any tab characters in the current paragraph. Warning: The lengths of aPos array and aVal array MUST BE equal to each other.

SetTextPr

Sets the paragraph text properties.

SetTopBorder

Specifies the border which will be displayed above a set of paragraphs which have the same set of paragraph border settings. The paragraphs of the same style going one by one are considered as a single block, so the border is added to the whole block rather than to every paragraph in this block.

SetUnderline

Specifies that the contents of this paragraph are displayed along with a line appearing directly below the character (less than all the spacing above and below the characters on the line).

SetVertAlign

Specifies the alignment which will be applied to the contents of this paragraph in relation to the default appearance of the paragraph text:

  • "baseline" - the characters in the current paragraph will be aligned by the default text baseline.
  • "subscript" - the characters in the current paragraph will be aligned below the default text baseline.
  • "superscript" - the characters in the current paragraph will be aligned above the default text baseline.
SetWidowControl

Specifies whether a single line of the current paragraph will be displayed on a separate page from the remaining content at display time by moving the line onto the following page.

WrapInMailMergeField

Wraps the paragraph content in a mail merge field.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a paragraph with the text in it aligned by the left side. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetJc("left");
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a paragraph with the text in it aligned by the right side. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetJc("right");
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a paragraph with the text in it aligned by the center. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetJc("center");
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a paragraph with the text in it aligned by both sides (justified). ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes. ");
oParagraph.AddText("These sentences are used to add lines for demonstrative purposes.");
oParagraph.SetJc("both");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiParagraph.docx");
builder.CloseFile();

Resulting document