ApiRun

new ApiRun()

Class representing a small text block called 'run'.

Methods

Name Description
AddColumnBreak

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

AddComment

Adds a comment to the current run. Please note that this run must be in the document.

AddDrawing

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

AddHyperlink

Adds a hyperlink to the current run.

AddLineBreak

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

AddPageBreak

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

AddTabStop

Adds a tab stop to the current run.

AddText

Adds some text to the current run.

ClearContent

Clears the content from the current run.

Copy

Creates a copy of the current run.

Delete

Deletes the current run.

GetClassType

Returns a type of the ApiRun class.

GetFontNames

Returns all font names from all elements inside the current run.

GetParentContentControl

Returns a content control that contains the current run.

GetParentTable

Returns a table that contains the current run.

GetParentTableCell

Returns a table cell that contains the current run.

GetRange

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

GetText

Returns a text from the text run.

GetTextPr

Returns the text properties of the current run.

RemoveAllElements

Removes all the elements from the current run.

Select

Selects the current run.

SetBold

Sets the bold property to the text character.

SetCaps

Specifies that any lowercase characters in the current text run are formatted for display only as their capital letter character equivalents.

SetColor

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

SetDoubleStrikeout

Specifies that the contents of the current run 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 text run.

SetHighlight

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

SetItalic

Sets the italic property to the text character.

SetLanguage

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

SetPosition

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

SetShd

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

SetSmallCaps

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

SetStrikeout

Specifies that the contents of the current run are displayed with a single horizontal line through the center of the line.

SetStyle

Sets a style to the current run.

SetTextPr

Sets the text properties to the current run.

SetUnderline

Specifies that the contents of the current 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

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

  • "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.
ToJSON

Converts the ApiRun object into the JSON object.

WrapInMailMergeField

Wraps a run in a mail merge field.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oRun = Api.CreateRun();
oRun.AddText("This is just a sample text.");
oRun.AddLineBreak();
oRun.AddTabStop();
oRun.AddTabStop();
oRun.AddText(" Nothing special.");
oRun.SetBold(true);
oParagraph.AddElement(oRun);
var oCopyRun = oRun.Copy();
oParagraph.AddLineBreak();
oParagraph.AddElement(oCopyRun);
oRun = Api.CreateRun();
var oDrawing = Api.CreateChart("bar3D", [
  [200, 240, 280],
  [250, 260, 280]
], ["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016], 4051300, 2347595, 24);
var oFill = Api.CreateSolidFill(Api.CreateRGBColor(51, 51, 51));
oDrawing.SetSeriesFill(oFill, 0, false);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
oDrawing.SetSeriesFill(oFill, 1, false);
oDrawing.SetVerAxisTitle("USD In Hundred Thousands", 10);
oDrawing.SetHorAxisTitle("Year", 11);
oDrawing.SetLegendPos("bottom");
oDrawing.SetShowDataLabels(false, false, true, false);
oDrawing.SetTitle("Financial Overview", 13);
oRun.AddDrawing(oDrawing);
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.AddText("onlyoffice document builder");
oRun.SetCaps(true);
oParagraph.AddLineBreak();
oParagraph.AddElement(oRun);
oRun.AddHyperlink("https://www.onlyoffice.com", "main page");
builder.SaveFile("docx", "ApiRun.docx");
builder.CloseFile();

Resulting document