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

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

    Example

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

    
    Class PdfInteractiveFormComboBoxFieldExample
        ''' <summary>
        ''' Creates a PDF document with the combo box fields.
        ''' </summary>
        ''' <param name="filename">The filename.</param>
        Public Shared Sub CreateDocumentWithComboBoxField(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 = 70
                Dim height As Single = 20
                ' create a rectangle that defines check 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 combo box field
                Dim comboBox As New Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormComboBoxField(document, "ComboBox1", rect, New String() {"Item1", "Item2", "Item3"})
                ' set the selected item
                comboBox.SelectedItem = "Item2"
                ' set the defaul selected item
                comboBox.DefaultSelectedItem = comboBox.SelectedItem
    
                ' set the border style
                comboBox.Annotation.BorderStyle = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyle(document)
                comboBox.Annotation.BorderStyle.Style = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyleType.Beveled
                comboBox.Annotation.BorderStyle.Width = 1
    
                ' set the appearance characteristics
                comboBox.Annotation.AppearanceCharacteristics = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationAppearanceCharacteristics(document)
                comboBox.Annotation.AppearanceCharacteristics.BorderColor = System.Drawing.Color.Gray
    
                ' sets the default appearance of text
                Dim font As Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont = document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman)
                comboBox.SetTextDefaultAppearance(font, 12, System.Drawing.Color.Black)
    
                ' add combo box field to the interactive form of document
                document.InteractiveForm.Fields.Add(comboBox)
    
                ' add annotation, associated with combobox field, to the page
                page.Annotations = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document)
                page.Annotations.Add(comboBox.Annotation)
    
                ' save the document
                document.Save(filename)
            End Using
        End Sub
    End Class
    
    
    
    class PdfInteractiveFormComboBoxFieldExample
    {
        /// <summary>
        /// Creates a PDF document with the combo box fields.
        /// </summary>
        /// <param name="filename">The filename.</param>
        public static void CreateDocumentWithComboBoxField(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 = 70;
                float height = 20;
                // create a rectangle that defines check 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 combo box field
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormComboBoxField comboBox = 
                    new Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormComboBoxField(
                        document, "ComboBox1", rect, new string[] { "Item1", "Item2", "Item3" });
                // set the selected item
                comboBox.SelectedItem = "Item2";
                // set the defaul selected item
                comboBox.DefaultSelectedItem = comboBox.SelectedItem;
                
                // set the border style
                comboBox.Annotation.BorderStyle = 
                    new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyle(document);
                comboBox.Annotation.BorderStyle.Style = 
                    Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationBorderStyleType.Beveled;
                comboBox.Annotation.BorderStyle.Width = 1;
                
                // set the appearance characteristics
                comboBox.Annotation.AppearanceCharacteristics = 
                    new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationAppearanceCharacteristics(document);
                comboBox.Annotation.AppearanceCharacteristics.BorderColor = System.Drawing.Color.Gray;
                
                // sets the default appearance of text
                Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont font = document.FontManager.GetStandardFont(
                    Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman);
                comboBox.SetTextDefaultAppearance(font, 12, System.Drawing.Color.Black);
    
                // add combo box field to the interactive form of document
                document.InteractiveForm.Fields.Add(comboBox);
    
                // add annotation, associated with combobox field, to the page
                page.Annotations = new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document);
                page.Annotations.Add(comboBox.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.PdfInteractiveFormComboBoxField

    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