Get Started
Documentation

ApiParagraph

new ApiParagraph()

Class representing a paragraph.

Extends

Name Description
ApiParaPr Class representing a paragraph properties.

Methods

Name Description
AddColumnBreak Add column break to the current position and start the next element from a new column.
AddDrawing Add an object (image, shape or chart) to the current paragraph.
AddElement Add an element to the current paragraph.
AddLineBreak Add line break to the current position and start the next element from a new line.
AddPageBreak Add page break and start the next element from the next page.
AddPageNumber Insert the number of the current document page into the paragraph.
AddPagesCount Insert the number of pages in the current document into the paragraph.
AddTabStop Add a tab stop to the current paragraph.
AddText Add some text to the element.
GetClassType Get the type of this class.
GetElement Get the element of the paragraph using the position specified.
GetElementsCount Get the number of elements in the current paragraph.
GetNumbering Get a numbering definition and numbering level for the numbered list.
GetParagraphMarkTextPr Get 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 Get paragraph properties.
RemoveAllElements Remove all elements from the current paragraph.
RemoveElement Remove the element using the position specified.
SetBetweenBorder Specify the border which will be displayed between each paragraph in a set of paragraphs which have the same set of paragraph border settings.
SetBottomBorder Specify the border which will be displayed below a set of paragraphs which have the same paragraph border settings.
SetContextualSpacing Specify that any space before or after this paragraph set using the spacing element ApiParaPr.SetSpacingBefore or ApiParaPr.SetSpacingAfter, should not be applied when the preceding and following paragraphs are of the same paragraph style, affecting the top and bottom spacing respectively.
SetIndFirstLine Set the paragraph first line indentation.
SetIndLeft Set the paragraph left side indentation.
SetIndRight Set the paragraph right side indentation.
SetJc Set paragraph contents justification.
SetKeepLines Specify that when rendering this document using a page view, all lines of this paragraph are maintained on a single page whenever possible.
SetKeepNext Specify that when rendering this document using a paginated view, the contents of this paragraph are at least partly rendered on the same page as the following paragraph whenever possible.
SetLeftBorder Specify the border which will be displayed at the left side of the page around the specified paragraph.
SetNumbering Specify that the current paragraph references a numbering definition instance in the current document.
SetNumPr Specify that the current paragraph references a numbering definition instance in the current document.
SetPageBreakBefore Specify that when rendering this document using a paginated view, the contents of this paragraph are rendered at the beginning of a new page in the document.
SetRightBorder Specify the border which will be displayed at the right side of the page around the specified paragraph.
SetShd Specify the shading applied to the contents of the paragraph.
SetSpacingAfter Set 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 Set 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 Set 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.
SetStyle Set paragraph style.
SetTabs Specify a sequence of custom tab stops which will be used for any tab characters in the current paragraph.
SetTopBorder Specify the border which will be displayed above a set of paragraphs which have the same set of paragraph border settings.
SetWidowControl Specify whether a single line of this paragraph will be prevented from being displayed on a separate page from the remaining content at display time by moving the line onto the following page.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph;
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", "SetJc.docx");
builder.CloseFile();

Resulting document