VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree.InteractiveForms Namespace / PdfInteractiveFormListBoxField Class
Members Object Syntax Remarks Example Hierarchy Requirements SeeAlso
In This Topic
    PdfInteractiveFormListBoxField Class
    In This Topic
    Provides information about interactive form field that defines list box.
    Object Model
    PdfBrush PdfFont PdfInteractiveFormFieldAdditionalActions PdfInteractiveFormField PdfWidgetAnnotation PdfInteractiveFormFieldList PdfDocument PdfIndirectReference PdfBasicObject PdfInteractiveFormListBoxField
    Syntax
    'Declaration
    
    Public Class PdfInteractiveFormListBoxField
       Inherits PdfInteractiveFormChoiceField
    
    
    public class PdfInteractiveFormListBoxField : PdfInteractiveFormChoiceField
    
    
    public __gc class PdfInteractiveFormListBoxField : public PdfInteractiveFormChoiceField*
    
    
    public ref class PdfInteractiveFormListBoxField : public PdfInteractiveFormChoiceField^
    
    
    Remarks

    Use the SelectedItem or SelectedItems property for changing the field value.
    Use the DefaultSelectedItem or DefaultSelectedItems property for changing the default value of the field.

    Example

    Here is an example that shows how to create a PDF document with ListBox field:

    
    Class PdfInteractiveFormListBoxFieldExample
        ''' <summary>
        ''' Creates a PDF document with the list box field.
        ''' </summary>
        ''' <param name="filename">The filename.</param>
        Public Shared Sub CreateDocumentWithListBoxField(filename As String)
            ' create PDF document
            Using document As New Vintasoft.Imaging.Pdf.PdfDocument()
                ' create interactive form in PDF document
                document.InteractiveForm = New Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm(document)
    
                ' specify that the viewer application must construct appearance streams and
                ' appearance properties for all widget annotations
                document.InteractiveForm.NeedAppearances = True
    
                ' create an empty page
                Dim page As New Vintasoft.Imaging.Pdf.Tree.PdfPage(document, Vintasoft.Imaging.PaperSizeKind.A4)
                ' add page to the document
                document.Pages.Add(page)
    
                Dim width As Single = 60
                Dim height As Single = 70
                ' create a rectangle that defines list box position on PDF page
                Dim rect As New System.Drawing.RectangleF((page.Size.Width - width) / 2, ((page.Size.Height - height) / 3) * 2, width, height)
    
                ' create a list box field
                Dim listBox As New Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormListBoxField(document, "ListBox1", rect, New String() {"Item1", "Item2", "Item3"})
                ' set the selected item
                listBox.SelectedItem = "Item2"
                ' set yje default selected item
                listBox.DefaultSelectedItem = listBox.SelectedItem
    
                ' set the border style
                listBox.Annotation.BorderStyle = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyle(document)
                listBox.Annotation.BorderStyle.Style = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyleType.Beveled
                listBox.Annotation.BorderStyle.Width = 1
    
                ' set the appearance characteristics
                listBox.Annotation.AppearanceCharacteristics = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationAppearanceCharacteristics(document)
                listBox.Annotation.AppearanceCharacteristics.BorderColor = System.Drawing.Color.Gray
    
                ' set the default appearance of text
                Dim font As Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont = document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman)
                listBox.SetTextDefaultAppearance(font, 12, System.Drawing.Color.Black)
    
                ' add the list box field to the interactive form of document
                document.InteractiveForm.Fields.Add(listBox)
    
                ' add annotation, associated with list box field, to the page
                page.Annotations = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document)
                page.Annotations.Add(listBox.Annotation)
    
                ' save the document
                document.Save(filename)
            End Using
        End Sub
    End Class
    
    
    
    class PdfInteractiveFormListBoxFieldExample
    {
        /// <summary>
        /// Creates a PDF document with the list box field.
        /// </summary>
        /// <param name="filename">The filename.</param>
        public static void CreateDocumentWithListBoxField(string filename)
        {
            // create PDF document
            using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument())
            {
                // create interactive form in PDF document
                document.InteractiveForm = 
                    new Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm(document);
    
                // specify that the viewer application must construct appearance streams and
                // appearance properties for all widget annotations
                document.InteractiveForm.NeedAppearances = true;
    
                // create an empty page
                Vintasoft.Imaging.Pdf.Tree.PdfPage page = new Vintasoft.Imaging.Pdf.Tree.PdfPage(
                    document, Vintasoft.Imaging.PaperSizeKind.A4);
                // add page to the document
                document.Pages.Add(page);
    
                float width = 60;
                float height = 70;
                // create a rectangle that defines list box position on PDF page
                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(
                    (page.Size.Width - width) / 2,
                    ((page.Size.Height - height) / 3) * 2,
                    width, height);
    
                // create a list box field
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormListBoxField listBox = 
                    new Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormListBoxField(
                        document, "ListBox1", rect, new string[] { "Item1", "Item2", "Item3" });
                // set the selected item
                listBox.SelectedItem = "Item2";
                // set yje default selected item
                listBox.DefaultSelectedItem = listBox.SelectedItem;
                
                // set the border style
                listBox.Annotation.BorderStyle = 
                    new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyle(document);
                listBox.Annotation.BorderStyle.Style = 
                    Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyleType.Beveled;
                listBox.Annotation.BorderStyle.Width = 1;
                
                // set the appearance characteristics
                listBox.Annotation.AppearanceCharacteristics = 
                    new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationAppearanceCharacteristics(document);
                listBox.Annotation.AppearanceCharacteristics.BorderColor = System.Drawing.Color.Gray;
    
                // set the default appearance of text
                Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont font = document.FontManager.GetStandardFont(
                    Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman);
                listBox.SetTextDefaultAppearance(font, 12, System.Drawing.Color.Black);
    
                // add the list box field to the interactive form of document
                document.InteractiveForm.Fields.Add(listBox);
    
                // add annotation, associated with list box field, to the page
                page.Annotations = new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document);
                page.Annotations.Add(listBox.Annotation);
    
                // save the document
                document.Save(filename);
            }
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
          Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField
             Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormChoiceField
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormListBoxField

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also