В этом примере кода показано, как создать документ, содержащий элемент FormDropDown.
Полный код
using SautinSoft.Document;
using System.Linq;
namespace Example
{
class Program
{
static void Main(string[] args)
{
// Get your free 100-day key here:
// https://sautinsoft.com/start-for-free/
FormDropDown();
}
/// <summary>
/// Creates a document containing FormDropDown element.
/// </summary>
/// <remarks>
/// Details: https://sautinsoft.com/products/document/help/net/developer-guide/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 demonstration purposes.
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
}
}
}
Imports SautinSoft.Document
Imports System.Linq
Module Sample
Sub Main()
FormDropDown()
End Sub
''' Get your free 100-day key here:
''' https://sautinsoft.com/start-for-free/
''' <summary>
''' Creates a document containing FormDropDown element.
''' </summary>
''' <remarks>
''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/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 demonstration purposes.
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
End Sub
End Module
Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу support@sautinsoft.com или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже: