Document .Net - Advanced Features

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)
        {
            FormDropDown();
        }
        /// <summary>
        /// Creates a document containing FormDropDown element.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/advanced.php
        /// </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;

            par.Inlines.Add(field.Field);
            
            // Save our document.
            dc.Save(filePath);

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

Download.

        
            Imports SautinSoft.Document
Imports System.Linq


Module Sample
    Sub Main()
        FormDropDown()
    End Sub

    ''' <summary>
    ''' Creates a document containing FormDropDown element.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/examples/advanced.php
    ''' </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

        par.Inlines.Add(field.Field)

        ' Save our document.
        dc.Save(filePath)

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

Download.


If you need a new code example or have a question: email us at support@sautinsoft.com 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.

© SautinSoft 2002 - 2019