Class PdfListBoxField
Represents list box field of the PDF form.
Implements
System.ComponentModel.INotifyPropertyChanged
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Portable.dll
Syntax
public class PdfListBoxField : PdfListField, IPdfWrapper, INotifyPropertyChanged
Remarks
This PdfListBoxField class is used to create the list box field in PDF forms. Please refer the UG docuemntation link https://help.syncfusion.com/file-formats/pdf/working-with-forms#adding-the-list-box-field for more details.
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)
Constructors
PdfListBoxField(PdfPageBase, String)
Initializes a new instance of the PdfListBoxField class with the specific page and name.
Declaration
public PdfListBoxField(PdfPageBase page, string name)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | Page the field to be placed on. |
System.String | name | 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.
Declaration
public bool ComplexScript { get; set; }
Property Value
Type |
---|
System.Boolean |
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)
MultiSelect
Gets or sets a value indicating whether the field is multiselectable.
Declaration
public bool MultiSelect { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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.
Declaration
protected override void DrawAppearance(PdfTemplate template)
Parameters
Type | Name | Description |
---|---|---|
PdfTemplate | template | The template. |
Overrides
Initialize()
Initializes an instance.
Declaration
protected override void Initialize()
Overrides
Implements
System.ComponentModel.INotifyPropertyChanged