Class PdfComboBoxField
Represents combo box field in the PDF Form.
Implements
System.ComponentModel.INotifyPropertyChanged
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfComboBoxField : PdfListField, IPdfWrapper, INotifyPropertyChanged
Remarks
This PdfComboBoxField class is used to create the combo box field in PDF forms. Please refer the UG docuemntation link https://help.syncfusion.com/file-formats/pdf/working-with-forms#adding-the-combo-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 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)
Constructors
PdfComboBoxField(PdfPageBase, String)
Initializes a new instance of the PdfComboBoxField class with the specific page and name.
Declaration
public PdfComboBoxField(PdfPageBase page, string name)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | Page of 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 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.
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 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)
Editable
Gets or sets a value indicating whether this PdfComboBoxField is editable.
Declaration
public bool Editable { 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 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.
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