How can I help you?
PdfComboBoxField
6 Feb 202613 minutes to read
PdfComboBoxField class represents the combo box field objects.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Gets the first page of the document
let page: PdfPage = document.getPage(0);
// Access the PDF form
let form: PdfForm = document.form;
// Create a new combo box field
let field: PdfComboBoxField = new PdfComboBoxField(page, 'list1', {x: 100, y: 60, width: 100, height: 50});
// Add list items to the field.
field.addItem(new PdfListFieldItem('English', 'English'));
field.addItem(new PdfListFieldItem('French', 'French'));
field.addItem(new PdfListFieldItem('German', 'German'));
// Sets the selected index
field.selectedIndex = 2;
// Sets the flag indicates whether the combo box allows multiple selections.
field.multiSelect = true;
// Add the field into PDF form
form.add(field);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Properties
Get backColor PdfColor
Gets the background color of the field.
Set backColor void
Sets the background color of the field.
| Parameter | Type | Description |
|---|---|---|
| value | PdfColor |
Array with R, G, B, A color values in between 0 to 255. |
Get border PdfInteractiveBorder
Gets the width, style and dash of the border of the field.
Set border void
Sets the width, style and dash of the border of the field.
| Parameter | Type | Description |
|---|---|---|
| value | PdfInteractiveBorder |
Border properties. |
Get borderColor PdfColor
Gets the border color of the field.
Set borderColor void
Sets the border color of the field.
| Parameter | Type | Description |
|---|---|---|
| value | PdfColor |
Array with R, G, B, A color values in between 0 to 255. |
Get bounds Rectangle
Gets the bounds.
Set bounds void
Sets the bounds.
| Parameter | Type | Description |
|---|---|---|
| value | Rectangle |
Bounds. |
Get color PdfColor
Gets the fore color of the field.
Set color void
Sets the fore color of the field.
| Parameter | Type | Description |
|---|---|---|
| value | PdfColor |
R, G, B color values in between 0 to 255. |
Get editable boolean
Gets the flag indicates whether the list field is editable.
Set editable void
Sets the flag indicates whether the list field is editable.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Indicates whether the list field is editable. |
Get export boolean
Gets a value indicating whether the field is allow to export data or not.
Set export void
Sets a value indicating whether the field is allow to export data or not.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Allow to export data or not. |
Get flatten boolean
Gets the boolean flag indicating whether the form field have been flattened or not.
Set flatten void
Sets the boolean flag indicating whether the form field have been flattened or not.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Flatten. |
Get font PdfFont
Gets the font of the field.
Set font void
Sets the font of the field.
| Parameter | Type | Description |
|---|---|---|
| value | PdfFont |
Font. |
Get form PdfForm
Gets the form object of the field (Read only).
Get itemsCount number
Gets the count of the loaded field items (Read only).
Get mappingName string
Gets the mapping name to be used when exporting interactive form field data from the document.
Set mappingName void
Sets the mapping name to be used when exporting interactive form field data from the document.
| Parameter | Type | Description |
|---|---|---|
| value | string |
Mapping name. |
Get multiSelect boolean
Gets the flag indicates whether the list field allows multiple selections.
Set multiSelect void
Sets the flag indicates whether the list field allows multiple selections.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Indicates whether the list field allows multiple selections. |
Get name string
Gets the name of the field (Read only).
Get page PdfPage
Gets the page object of the form field (Read only).
Get readOnly boolean
Gets a value indicating whether read only.
Set readOnly void
Sets a value indicating whether read only.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Read only or not. |
Get required boolean
Gets a value indicating whether the field is required.
Set required void
Sets a value indicating whether the field is required.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Required or not. |
Get rotate number
Gets the rotation angle of the field.
Set rotate void
Sets the rotation angle of the field.
| Parameter | Type | Description |
|---|---|---|
| value | number |
Rotation angle. |
Get rotationAngle PdfRotationAngle
Gets the rotation of the field (Read only).
Get selectedIndex number | number[]
Gets the selected item index or indexes.
Set selectedIndex void
Sets the selected item index or indexes.
| Parameter | Type | Description |
|---|---|---|
| value |
number | number[]
|
Selected index. |
Get selectedValue string | string[]
Gets the selected item value or values.
Set selectedValue void
Sets the selected item value or values.
| Parameter | Type | Description |
|---|---|---|
| value |
string | string[]
|
Selected values. |
Get tabIndex number
Gets the tab index of annotation in current page.
Set tabIndex void
Sets the tab index of a annotation in the current page.
| Parameter | Type | Description |
|---|---|---|
| value | number |
Index. |
Get textAlignment PdfTextAlignment
Gets the text alignment in a combo box field.
Set textAlignment void
Sets the text alignment in a combo box field.
| Parameter | Type | Description |
|---|---|---|
| value | PdfTextAlignment |
Text alignment. |
Get toolTip string
Gets the tool tip of the form field.
Set toolTip void
Sets the tool tip of the form field.
| Parameter | Type | Description |
|---|---|---|
| value | string |
Tooltip. |
Get visibility PdfFormFieldVisibility
Gets the form field visibility.
Set visibility void
Sets the form field visibility.
| Parameter | Type | Description |
|---|---|---|
| value | PdfFormFieldVisibility |
Visibility. |
Get visible boolean
Gets a value indicating the visibility of the field (Read only).
Set visible void
Sets a value indicating the visibility of the field.
Only applicable for newly created PDF form fields.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Or not. |
Methods
addItem
Add list item.
| Parameter | Type | Description |
|---|---|---|
| item | PdfListFieldItem |
Item to add. |
Returns number
getValue
Gets the value associated with the specified key.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Key. |
Returns string
itemAt
Gets the item at the specified index.
| Parameter | Type | Description |
|---|---|---|
| index | number |
Index of the field item. |
Returns PdfListFieldItem
removeItem
Remove the list item.
| Parameter | Type | Description |
|---|---|---|
| item | PdfListFieldItem |
Item to remove. |
Returns void
removeItemAt
Remove the list item from the specified index.
| Parameter | Type | Description |
|---|---|---|
| index | number |
Item index to remove. |
Returns void
setAppearance
Sets the flag to indicate the new appearance creation.
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
Set appearance. |
Returns void
setValue
Sets the value associated with the specified key.
| Parameter | Type | Description |
|---|---|---|
| name | string |
Key. |
| value | string |
Value associated with the key.. |
Returns void