Get Started
Usage API
More information

ApiParagraph

new ApiParagraph()

Class representing a paragraph.

Methods

Name Description
AddElement

Adds an element to the current paragraph.

AddLineBreak

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

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.

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.

GetNext

Returns the next paragraph.

GetParaPr

Returns the paragraph properties.

GetPrevious

Returns the previous 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.

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.

SetBullet

Sets the bullet or numbering to 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.

SetJc

Sets the paragraph contents justification.

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.

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.

Example

Copy code
builder.CreateFile("pptx");
var oPresentation = Api.GetPresentation();
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(0, 0, 255), 0);
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(61, 74, 107), 100000);
var oFill = Api.CreateRadialGradientFill([oGs1, oGs2]);
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var oShape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, oFill, oStroke);
oShape.SetPosition(608400, 1267200);
var oDocContent = oShape.GetDocContent();
var oParagraph = oDocContent.GetElement(0);
oParagraph.SetJc("left");
var oRun = Api.CreateRun();
oRun.AddText("Number of paragraph elements at this point: ");
oRun.AddTabStop();
oRun.AddText("" + oParagraph.GetElementsCount());
oParagraph.AddElement(oRun);
oParagraph.AddLineBreak();
oParagraph.AddText("This is a text after the line break.");
oParagraph.AddLineBreak();
oParagraph.AddText("This is just a sample text. After it three tab stops will be added.");
oParagraph.AddTabStop();
oParagraph.AddTabStop();
oParagraph.AddTabStop();
oParagraph.AddText("This is the text which starts after the tab stops.");
oParagraph = Api.CreateParagraph();
oParagraph.SetJc("left");
oParagraph.AddText("This is just a sample text that was copied.");
oDocContent.Push(oParagraph);
var oCopyParagraph = oParagraph.Copy();
oDocContent.Push(oCopyParagraph);
var sClassType = oParagraph.GetClassType();
oCopyParagraph.AddLineBreak();
oCopyParagraph.AddText("Class Type = " + sClassType);
oParagraph = Api.CreateParagraph();
oDocContent.Push(oParagraph);
oParagraph.SetIndFirstLine(1440);
var nIndFirstLine = oParagraph.GetIndFirstLine();
oParagraph.AddText("First line indent: " + nIndFirstLine);
oSlide.AddObject(oShape);
builder.SaveFile("pptx", "ApiParagraph.pptx");
builder.CloseFile();

Resulting document