ApiTextPr

new ApiTextPr()

Class representing the text properties.

Methods

Name Description
GetBold

Gets the bold property from the current text properties.

GetCaps

Specifies whether the text with the current text properties are capitalized.

GetClassType

Returns a type of the ApiTextPr class.

GetColor

Gets the RGB color from the current text properties.

GetDoubleStrikeout

Gets the double strikeout property from the current text properties.

GetFontFamily

Gets the font family from the current text properties.

GetFontSize

Gets the font size from the current text properties.

GetHighlight

Gets the highlight property from the current text properties.

GetItalic

Gets the italic property from the current text properties.

GetLanguage

Gets the language from the current text properties.

GetPosition

Gets the text position from the current text properties measured in half-points (1/144 of an inch).

GetShd

Gets the text shading from the current text properties.

GetSmallCaps

Specifies whether the text with the current text properties are displayed capitalized two points smaller than the actual font size.

GetSpacing

Gets the text spacing from the current text properties measured in twentieths of a point.

GetStrikeout

Gets the strikeout property from the current text properties.

GetStyle

Gets the style of the current text properties.

GetUnderline

Gets the underline property from the current text properties.

GetVertAlign

Gets the vertical alignment type from the current text properties.

SetBold

Sets the bold property to the text character.

SetCaps

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

SetColor

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

SetDoubleStrikeout

Specifies that the contents of the 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 added to the text properties and applied as a background to the contents of the current run/range/paragraph.

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 the 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 the 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 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 to the text.

SetUnderline

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

Converts the ApiTextPr object into the JSON object.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oTextPr = oDocument.GetDefaultTextPr();
oTextPr.SetFontSize(30);
oTextPr.SetBold(true);
oTextPr.SetCaps(true);
oTextPr.SetColor(255, 111, 61, false);
oTextPr.SetDoubleStrikeout(true);
oTextPr.SetFontFamily("Comic Sans MS");
oTextPr.SetHighlight(128, 128, 128, false);
oTextPr.SetItalic(true);
oTextPr.SetSpacing(80);
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a sample text to show the specified text properties.");
var sClassType = oTextPr.GetClassType();
oParagraph.AddLineBreak();
oParagraph.AddText("Class Type = " + sClassType);
builder.SaveFile("docx", "ApiTextPr.docx");
builder.CloseFile();

Resulting document