Table of Contents

Class PdfListBoxField

Namespace
Syncfusion.Pdf.Interactive
Assembly
Syncfusion.Pdf.Portable.dll

Represents list box field of the PDF form.

public class PdfListBoxField : PdfListField, INotifyPropertyChanged
Inheritance
PdfListBoxField
Implements
Inherited Members

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;
//Add the items to the list box
listBox.Items.Add(new PdfListFieldItem("English", "English"));
listBox.Items.Add(new PdfListFieldItem("French", "French"));
listBox.Items.Add(new PdfListFieldItem("German", "German"));
//Select the item
listBox.SelectedIndex = 2;
//Set the multiselect option
listBox.MultiSelect = true;                    
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
'Add the items to the list box
listBox.Items.Add(New PdfListFieldItem("English", "English"))
listBox.Items.Add(New PdfListFieldItem("French", "French"))
listBox.Items.Add(New PdfListFieldItem("German", "German"))
'Select the item
listBox.SelectedIndex = 2
'Set the multiselect option
listBox.MultiSelect = True
document.Save("Form.pdf")
document.Close(True)

Remarks

This PdfListBoxField class is used to create the list box field in PDF forms. Please refer the UG docuemntation link for more details.

Constructors

PdfListBoxField(PdfPageBase, string)

Initializes a new instance of the PdfListBoxField class with the specific page and name.

public PdfListBoxField(PdfPageBase page, string name)

Parameters

page PdfPageBase

Page the field to be placed on.

name string

The name of the field.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;
//Add the items to the list box
listBox.Items.Add(new PdfListFieldItem("English", "English"));
listBox.Items.Add(new PdfListFieldItem("French", "French"));
listBox.Items.Add(new PdfListFieldItem("German", "German"));
//Select the item
listBox.SelectedIndex = 2;
//Set the multiselect option
listBox.MultiSelect = true;                    
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
'Add the items to the list box
listBox.Items.Add(New PdfListFieldItem("English", "English"))
listBox.Items.Add(New PdfListFieldItem("French", "French"))
listBox.Items.Add(New PdfListFieldItem("German", "German"))
'Select the item
listBox.SelectedIndex = 2
'Set the multiselect option
listBox.MultiSelect = True
document.Save("Form.pdf")
document.Close(True)
See Also

Properties

ComplexScript

Gets or sets the complex script language support.

public bool ComplexScript { get; set; }

Property Value

bool

Examples

//Create a new PDF document.
 PdfDocument document = new PdfDocument();
 //Add a new PDF page.
 PdfPage page = document.Pages.Add();
 //Create font.
 Font font = new Font("Tahoma", 10f);
 //Create a new PDF font instance.
 PdfFont pdfFont = new PdfTrueTypeFont(font, FontStyle.Regular, 10f, true, true);
 //Create a new list box field.
 PdfListBoxField listBoxField = new PdfListBoxField(page, "list1");
 //Set bounds
 listBoxField.Bounds = new RectangleF(0, 0, 300, 20);
 //Set font.
 listBoxField.Font = pdfFont;
 //Add items.
 listBoxField.Items.Add(new PdfListFieldItem("สวัสดีชาวโลก", "One"));
 listBoxField.Items.Add(new PdfListFieldItem("สวัสดีชาวโลก", "Two"));
 //Set selected index.
 listBoxField.SelectedIndex = new int[] {0};
 //Enable complex script.
 listBoxField.ComplexScript = true;
 //Add field to form.
 document.Form.Fields.Add(listBoxField);
 document.Form.SetDefaultAppearance(false)
 //Save the document.
 document.Save("output.pdf");
 //Close the document.
 document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Add a new PDF page.
Dim page As PdfPage = document.Pages.Add()
'Create font.
Dim font As New Font("Tahoma", 10F)
'Create a new PDF font instance.
Dim pdfFont As PdfFont = New PdfTrueTypeFont(font, FontStyle.Regular, 10F, True, True)
'Create a new list box field.
Dim listBoxField As New PdfListBoxField(page, "list1")
'Set bounds
listBoxField.Bounds = New RectangleF(0, 0, 300, 20)
'Set font.
listBoxField.Font = pdfFont
'Add items.
listBoxField.Items.Add(New PdfListFieldItem("สวัสดีชาวโลก", "One"))
listBoxField.Items.Add(New PdfListFieldItem("สวัสดีชาวโลก", "Two"))
'Set selected index.
listBoxField.SelectedIndex = New Integer() {0}
'Enable complex script.
listBoxField.ComplexScript = True
'Add field to form.
document.Form.Fields.Add(listBoxField)
document.Form.SetDefaultAppearance(False)
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
See Also

MultiSelect

Gets or sets a value indicating whether the field is multiselectable.

public bool MultiSelect { get; set; }

Property Value

bool

true if multiselectable; otherwise, false.

Examples

//Create a new PDf document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
//Create list box
PdfListBoxField listBox = new PdfListBoxField(page, "list1");
//Add the field to listbox.
document.Form.Fields.Add(listBox);
//Set the properties.
listBox.Bounds = new RectangleF(100, 350, 100, 50);
listBox.HighlightMode = PdfHighlightMode.Outline;
//Add the items to the list box
listBox.Items.Add(new PdfListFieldItem("English", "English"));
listBox.Items.Add(new PdfListFieldItem("French", "French"));
listBox.Items.Add(new PdfListFieldItem("German", "German"));
//Select the item
listBox.SelectedIndex = 2;
//Set the multiselect option
listBox.MultiSelect = true;                    
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
'Create list box
Dim listBox As PdfListBoxField = New PdfListBoxField(page, "list1")
'Add the field to listbox.
document.Form.Fields.Add(listBox)
'Set the properties.
listBox.Bounds = New RectangleF(100, 350, 100, 50)
listBox.HighlightMode = PdfHighlightMode.Outline
'Add the items to the list box
listBox.Items.Add(New PdfListFieldItem("English", "English"))
listBox.Items.Add(New PdfListFieldItem("French", "French"))
listBox.Items.Add(New PdfListFieldItem("German", "German"))
'Select the item
listBox.SelectedIndex = 2
'Set the multiselect option
listBox.MultiSelect = True
document.Save("Form.pdf")
document.Close(True)
See Also

Methods

DrawAppearance(PdfTemplate)

Draws the appearance.

protected override void DrawAppearance(PdfTemplate template)

Parameters

template PdfTemplate

The template.

See Also

Initialize()

Initializes an instance.

protected override void Initialize()
See Also

See Also