Get Started
Usage API
More information

ApiTextForm

new ApiTextForm()

Class representing a document text form.

Properties

Name Type Description
comb boolean

Specifies if the text form should be a comb of characters with the same cell width. The maximum number of characters must be set to a positive value.

maxCharacters number

The maximum number of characters in the text form.

cellWidth number

The cell width for each character measured in millimeters. If this parameter is not specified or equal to 0 or less, then the width will be set automatically.

multiLine boolean

Specifies if the current fixed size text form is multiline or not.

autoFit boolean

Specifies if the text form content should be autofit, i.e. whether the font size adjusts to the size of the fixed size form.

Methods

Name Description
Clear

Clears the current form.

GetCharactersLimit

Returns a limit of the text form characters.

GetClassType

Returns a type of the ApiFormBase class.

GetFormKey

Returns the current form key.

GetFormType

Returns a type of the current form.

GetText

Returns the text from the current form.

GetTextPr

Returns the text properties from the current form.

GetTipText

Returns the tip text of the current form.

GetWrapperShape

Returns a shape in which the form is placed to control the position and size of the fixed size form frame. The null value will be returned for the inline forms.

IsAutoFit

Checks if the text form content is autofit, i.e. whether the font size adjusts to the size of the fixed size form.

IsComb

Checks if the text form is a comb of characters with the same cell width.

IsFixed

Checks if the current form is fixed size.

IsMultiline

Checks if the current text form is multiline.

IsRequired

Checks if the current form is required.

SetAutoFit

Specifies if the text form content should be autofit, i.e. whether the font size adjusts to the size of the fixed size form.

SetBackgroundColor

Sets the background color to the current form.

SetBorderColor

Sets the border color to the current form.

SetCellWidth

Sets the cell width to the applied comb of characters.

SetCharactersLimit

Sets a limit to the text form characters.

SetComb

Specifies if the text form should be a comb of characters with the same cell width. The maximum number of characters must be set to a positive value.

SetFormKey

Sets a key to the current form.

SetMultiline

Specifies if the current text form should be miltiline.

SetPlaceholderText

Sets the placeholder text to the current form. Can't be set to checkbox or radio button.

SetRequired

Specifies if the current form should be required.

SetText

Sets the text to the current text form.

SetTextPr

Sets the text properties to the current form.

SetTipText

Sets the tip text to the current form.

ToFixed

Converts the current form to a fixed size form.

ToInline

Converts the current form to an inline form. Picture form can't be converted to an inline form, it's always a fixed size object.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oTextForm = Api.CreateTextForm({"key": "Personal information", "tip": "Enter your first name", "required": true, "placeholder": "First name", "multiLine": false, "autoFit": false});
var oParagraph = oDocument.GetElement(0);
oParagraph.AddElement(oTextForm);
oTextForm.SetCharactersLimit(5);
oTextForm.SetText("John Smith");
oTextForm.SetComb(true);
var nLimit = oTextForm.GetCharactersLimit();
var bComb = oTextForm.IsComb();
var bMultiline = oTextForm.IsMultiline();
var bAutoFit = oTextForm.IsAutoFit();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Characters limit: " + nLimit);
oParagraph.AddLineBreak();
oParagraph.AddText("The first text form from this document is comb: " + bComb);
oParagraph.AddLineBreak();
oParagraph.AddText("The first text form from this document is multiline: " + bMultiline);
oParagraph.AddLineBreak();
oParagraph.AddText("The first text form from this document is autofit: " + bAutoFit);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiTextForm.docx");
builder.CloseFile();

Resulting document