Get Started
Documentation

ApiParagraph

new ApiParagraph()

Class representing a paragraph.

Methods

Name Description
AddColumnBreak

Add column break to the current position and start the next element from a new column.

AddComment

Adds a comment to the paragraph.

AddDrawing

Add an object (image, shape or chart) to the current paragraph.

AddElement

Add an element to the current paragraph.

AddHyperlink

Add a hyperlink to a paragraph.

AddInlineLvlSdt

Add a inline container

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. This method works for the paragraphs in the document header/footer only.

AddPagesCount

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

AddTabStop

Add a tab stop to the current paragraph.

AddText

Add some text to the element.

Copy

Create a copy of the paragraph. Ingonore comments, footnote references, complex fields

Delete

Delete current paragraph.

GetAllCharts

Gets the collection of chart objects in the Paragraph.

GetAllContentControls

Gets the collection of content control objects in the Paragraph.

GetAllDrawingObjects

Gets the collection of drawing objects in the paragraph.

GetAllImages

Gets the collection of image objects in the Paragraph.

GetAllShapes

Gets the collection of shapes objects in the Paragraph.

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.

GetLastRunWithText

Get last Run with text in the current paragraph

GetNext

Gets the next 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.

GetParentContentControl

Gets the content control that contains the paragraph.

GetParentTable

Gets the table that contains the paragraph.

GetParentTableCell

Gets the table cell that contains the paragraph.

GetPrevious

Gets the Previous paragraph.

GetRange

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

GetText

Gets text of the paragraph.

GetTextPr

Gets text properties of the paragraph.

InsertInContentControl

Wraps the paragraph object with a rich text content control.

InsertParagraph

Inserts a paragraph at the specified position.

Last

Get the last no empty element of the paragraph.

Push

Add an element to the current paragraph.

RemoveAllElements

Remove all elements from the current paragraph. When all 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

Remove the element using the position specified. If the element you remove is the last paragraph element (i.e. all 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 the scope of a paragraph object. The search results are a collection of ApiRange objects.

Select

Select a paragraph.

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.

SetBold

Set the bold property to the text character.

SetBottomBorder

Specify 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

Set the bullet or numbering to the current paragraph.

SetCaps

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

SetColor

Set the text color for the current paragraph in the RGB format.

SetContextualSpacing

Specify 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

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

SetFontFamily

Set all 4 font slots with the specified font family.

SetFontSize

Set the font size for the characters of the current paragraph.

SetHighlight

Specify a highlighting color in the RGB format which is applied as a background for the contents of the current paragraph.

SetIndFirstLine

Set the paragraph first line indentation.

SetIndLeft

Set the paragraph left side indentation.

SetIndRight

Set the paragraph right side indentation.

SetItalic

Set the italic property to the text character.

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.

SetPosition

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

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 current paragraph.

SetSmallCaps

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

SetSpacing

Set text spacing measured in twentieths of a point.

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.

SetStrikeout

Specify 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

Specify 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 text properties of the paragraph.

SetTopBorder

Specify 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

Specify 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

Specify 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

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