Get Started
Documentation

ApiRun

new ApiRun()

Class representing a small text block calling 'run'.

Methods

Name Description
AddColumnBreak

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

AddDrawing

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

AddLineBreak

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

AddPageBreak

Add a page break and start the next element from a new page.

AddTabStop

Add a tab stop to the current run.

AddText

Add some text to this run.

ClearContent

Remove all content from the current run.

Copy

Create a copy of the run.

GetClassType

Get the type of this class.

GetTextPr

Get the text properties of the current run.

SetBold

Set the bold property to the text character.

SetCaps

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

SetColor

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

SetDoubleStrikeout

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

SetFill

Set the text color for the current text run.

SetFontFamily

Set all 4 font slots with the specified font family.

SetFontSize

Set the font size for the characters of the current text run.

SetHighlight

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

SetItalic

Set the italic property to the text character.

SetLanguage

Specify the languages which will be used to check spelling and grammar (if requested) when processing the contents of this text run.

SetPosition

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

SetShd

Specify the shading applied to the contents of the current text run.

SetSmallCaps

Specify that all small letter characters in this text run 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.

SetStrikeout

Specify that the contents of this run are displayed with a single horizontal line through the center of the line.

SetStyle

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

SetUnderline

Specify that the contents of this run 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 run in relation to the default appearance of the run text:

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

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oRun;
oParagraph = oDocument.GetElement(0);
oRun = Api.CreateRun();
oRun.AddText("This is just a sample text. Nothing special.");
oParagraph.AddElement(oRun);
builder.SaveFile("docx", "AddText.docx");
builder.CloseFile();

Resulting document