Advanced Features

This code example shows how to create a document containing FormDropDown element.

Code Examples

using SautinSoft.Document;
using System.Linq;

namespace Example
    class Program
        static void Main(string[] args)
        /// <summary>
        /// Creates a document containing FormDropDown element.
        /// </summary>
        /// <remarks>
        /// Details:
        /// </remarks>
        static void FormDropDown()
            string filePath = @"Advanced.pdf";

            // Let's create document.
            DocumentCore dc = new DocumentCore();
            dc.Content.End.Insert(new Paragraph(dc, "The paragraph with FormDropDown element: ").Content);
            Paragraph par = dc.GetChildElements(true, ElementType.Paragraph).FirstOrDefault() as Paragraph;

            FormDropDownData field = new Field(dc, FieldType.FormDropDown).FormData as FormDropDownData;
            field.Items.Add("First Item");
            field.Items.Add("Second Item");
            field.Items.Add("Third Item");
            field.SelectedItemIndex = 2;

            // Save our document.

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });


Imports SautinSoft.Document
Imports System.Linq

Module Sample
    Sub Main()
    End Sub

    ''' <summary>
    ''' Creates a document containing FormDropDown element.
    ''' </summary>
    ''' <remarks>
    ''' Details:
    ''' </remarks>
    Sub FormDropDown()
        Dim filePath As String = "Advanced.pdf"

        ' Let's create document.
        Dim dc As New DocumentCore()
        dc.Content.End.Insert((New Paragraph(dc, "The paragraph with FormDropDown element: ")).Content)
        Dim par As Paragraph = TryCast(dc.GetChildElements(True, ElementType.Paragraph).FirstOrDefault(), Paragraph)

        Dim field As FormDropDownData = TryCast((New Field(dc, FieldType.FormDropDown)).FormData, FormDropDownData)
        field.Items.Add("First Item")
        field.Items.Add("Second Item")
        field.Items.Add("Third Item")
        field.SelectedItemIndex = 2


        ' Save our document.

        ' Open the result for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
    End Sub
End Module


If you need a new code example or have a question: email us at or ask at Online Chat (right-bottom corner of this page) or use the Form below:

Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.