Click or drag to resize

DocumentBuilderInsertTextInput Method

Inserts a text form field at the current position.

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.1.24
Syntax
public Field InsertTextInput(
	string name,
	FormTextType textType,
	string format,
	string fieldValue,
	int maxLength
)

Parameters

name  String
The name of the form field. Can be an empty string.
textType  FormTextType
Specifies the type of the text form field.
format  String
Format string used to format the value of the form field.
fieldValue  String
Text that will be shown in the field.
maxLength  Int32
Maximum length the user can enter into the form field. Set to zero for unlimited length.

Return Value

Field
Field that was just inserted.
Example

See Developer Guide: How to insert field and forms elements using DocumentBuilder

How to insert field and forms elements using DocumentBuilder in C#
using System;
using SautinSoft.Document;
using System.Text;
using SautinSoft.Document.Drawing;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get your free 30-day key here:   
            // https://sautinsoft.com/start-for-free/
            InsertingField();
        }
        /// <summary>
        /// Generate document with forms and fields using DocumentBuilder.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/documentbuilder-inserting-field.php
        /// </remarks>

        static void InsertingField()
        {
            DocumentCore dc = new DocumentCore();
            DocumentBuilder db = new DocumentBuilder(dc);

            string resultPath = @"Result.pdf";
            string[] items = { "One", "Two", "Three", "Four", "Five" };

            // Insert the formatted text into the document using DocumentBuilder.
            db.CharacterFormat.FontName = "Verdana";
            db.CharacterFormat.Size = 16;
            db.CharacterFormat.FontColor = Color.Orange;
            db.Writeln("Generate document with forms and fields using DocumentBuilder.");
            db.CharacterFormat.ClearFormatting();

            db.Write(@"{ TIME   \* MERGEFORMAT } - ");
            db.InsertField("TIME");
            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak);

            db.InsertTextInput("TextInput", FormTextType.RegularText, "", "Insert Text Input", 0);
            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak);

            db.InsertCheckBox("CheckBox", true, 0);
            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak);

            db.InsertComboBox("DropDown", items, 3);

            // Save our document into PDF format.
            dc.Save(resultPath, new PdfSaveOptions());

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(resultPath) { UseShellExecute = true });
        }
    }
}
How to insert field and forms elements using DocumentBuilder in VB.Net
Imports System
Imports SautinSoft.Document
Imports System.Text
Imports SautinSoft.Document.Drawing

Namespace Example
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            InsertingField()
        End Sub
                ''' Get your free 30-day key here:   
                ''' https://sautinsoft.com/start-for-free/
        ''' <summary>
        ''' Generate document with forms and fields using DocumentBuilder.
        ''' </summary>
        ''' <remarks>
        ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/documentbuilder-inserting-field.php
        ''' </remarks>

        Private Shared Sub InsertingField()
            Dim dc As New DocumentCore()
            Dim db As New DocumentBuilder(dc)

            Dim resultPath As String = "result.pdf"
            Dim items() As String = {"One", "Two", "Three", "Four", "Five"}

            ' Insert the formatted text into the document using DocumentBuilder.
            db.CharacterFormat.FontName = "Verdana"
            db.CharacterFormat.Size = 16
            db.CharacterFormat.FontColor = Color.Orange
            db.Writeln("Generate document with forms and fields using DocumentBuilder.")
            db.CharacterFormat.ClearFormatting()

            db.Write("{ TIME   \* MERGEFORMAT } - ")
            db.InsertField("TIME")
            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak)

            db.InsertTextInput("TextInput", FormTextType.RegularText, "", "Insert Text Input", 0)
            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak)

            db.InsertCheckBox("CheckBox", True, 0)
            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak)

            db.InsertComboBox("DropDown", items, 3)

            ' Save our document into PDF format.
            dc.Save(resultPath, New PdfSaveOptions())

            ' Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(resultPath) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also