Click or drag to resize

DocumentBuilderInsertCheckBox(String, Boolean, Int32) Method

Inserts a checkbox form field at the current position.

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.1.24
Syntax
public Field InsertCheckBox(
	string name,
	bool checkedValue,
	int size
)

Parameters

name  String
The name of the form field. Can be an empty string. The value longer than 20 characters will be truncated.
checkedValue  Boolean
Checked status of the checkbox form field.
size  Int32
Specifies the size of the checkbox in points. Specify 0 for MS Word to calculate the size of the checkbox automatically.

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