Table of Contents

Class PdfComboBoxField

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

Represents combo box field in the PDF Form.

public class PdfComboBoxField : PdfListField, INotifyPropertyChanged
Inheritance
PdfComboBoxField
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 a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");   
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
//Add it to document
document.Form.Fields.Add(positionComboBox);
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 a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox") 
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
'Add it to document
document.Form.Fields.Add(positionComboBox)
document.Save("Form.pdf")
document.Close(True)

Remarks

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

Constructors

PdfComboBoxField(PdfPageBase, string)

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

public PdfComboBoxField(PdfPageBase page, string name)

Parameters

page PdfPageBase

Page of 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 a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");    
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
//Add it to document
document.Form.Fields.Add(positionComboBox);
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 a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")     
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
'Add it to document
document.Form.Fields.Add(positionComboBox)
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 combo box field.
PdfComboBoxField comboBox = new PdfComboBoxField(page, "combo");
//Set bounds
comboBox.Bounds = new RectangleF(0, 0, 300, 20);
//Set font.
comboBox.Font = pdfFont;
//Add items.
comboBox.Items.Add(new PdfListFieldItem("สวัสดีชาวโลก", "One"));
comboBox.Items.Add(new PdfListFieldItem("สวัสดีชาวโลก", "Two"));
//Set selected index.
comboBox.SelectedIndex = 0;
//Enable complex script.
comboBox.ComplexScript = true;
//Add field to form.
document.Form.Fields.Add(comboBox);
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 combo box field.
Dim comboBox As New PdfComboBoxField(page, "combo")
'Set bounds
comboBox.Bounds = New RectangleF(0, 0, 300, 20)
'Set font.
comboBox.Font = pdfFont
'Add items.
comboBox.Items.Add(New PdfListFieldItem("สวัสดีชาวโลก", "One"))
comboBox.Items.Add(New PdfListFieldItem("สวัสดีชาวโลก", "Two"))
'Set selected index.
comboBox.SelectedIndex = 0
'Enable complex script.
comboBox.ComplexScript = True
'Add field to form.
document.Form.Fields.Add(comboBox)
document.Form.SetDefaultAppearance(False)
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
See Also

Editable

Gets or sets a value indicating whether this PdfComboBoxField is editable.

public bool Editable { get; set; }

Property Value

bool

true if editable; 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 a combo box
PdfComboBoxField positionComboBox = new PdfComboBoxField(page, "positionComboBox");
positionComboBox.Editable = true
positionComboBox.Bounds = new RectangleF(100, 115, 200, 20);
positionComboBox.Font = font;
positionComboBox.Editable = true;
//Add it to document
document.Form.Fields.Add(positionComboBox);
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 a combo box
Dim positionComboBox As PdfComboBoxField = New PdfComboBoxField(page, "positionComboBox")        
positionComboBox.Editable = True
positionComboBox.Bounds = New RectangleF(100, 115, 200, 20)
positionComboBox.Font = font
positionComboBox.Editable = True
'Add it to document
document.Form.Fields.Add(positionComboBox)
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