This sample shows how to read items of combo boxes in a PDF document.

You can access all widgets associated with a page using PdfPage.Widgets property. This method returns readonly collection of PdfWidget objects.

PdfComboBox class is a child of the PdfWidget class. All combo box items can be retrieved using PdfComboBox.Items property.

C#
using System.Windows.Forms;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class ReadComboBoxItems
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            using (PdfDocument pdf = new PdfDocument("Sample data/ComboBoxes.pdf"))
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                foreach (PdfWidget widget in pdf.Pages[0].Widgets)
                {
                    PdfComboBox comboBox = widget as PdfComboBox;
                    if (comboBox != null)
                    {
                        sb.Append("Combobox '");
                        sb.Append(comboBox.Name);
                        sb.Append("' contains following items:\n");

                        foreach (PdfListItem item in comboBox.Items)
                        {
                            sb.Append(item);
                            sb.Append("\n");
                        }

                        sb.Append("\n");
                    }
                }

                if (sb.Length == 0)
                    MessageBox.Show("No combo boxes found on first page");
                else
                    MessageBox.Show(sb.ToString());
            }
        }
    }
}
VB
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class ReadComboBoxItems
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Using pdf As New PdfDocument("Sample data/ComboBoxes.pdf")

                Dim sb As New System.Text.StringBuilder()
                For Each widget As PdfWidget In pdf.Pages(0).Widgets
                    Dim comboBox As PdfComboBox = TryCast(widget, PdfComboBox)
                    If comboBox IsNot Nothing Then
                        sb.Append("Combobox '")
                        sb.Append(comboBox.Name)
                        sb.Append("' contains following items:" & vbLf)

                        For Each item As PdfListItem In comboBox.Items
                            sb.Append(item)
                            sb.Append(vbLf)
                        Next

                        sb.Append(vbLf)
                    End If
                Next

                If sb.Length = 0 Then
                    MessageBox.Show("No combo boxes found on first page")
                Else
                    MessageBox.Show(sb.ToString())
                End If

            End Using
        End Sub
    End Class
End Namespace