@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
4,981 lines • 183 kB
TypeScript
import { _PdfDictionary, _PdfReference } from './../pdf-primitives';
import { _PdfCrossReference } from './../pdf-cross-reference';
import { PdfForm } from './form';
import { PdfRadioButtonListItem, PdfStateItem, PdfWidgetAnnotation, PdfListFieldItem, _PaintParameter, PdfInteractiveBorder } from './../annotations/annotation';
import { _PdfCheckFieldState, PdfFormFieldVisibility, _FieldFlag, PdfTextAlignment, PdfHighlightMode, PdfBorderStyle, PdfRotationAngle } from './../enumerator';
import { PdfPage } from './../pdf-page';
import { PdfTemplate } from './../graphics/pdf-template';
import { PdfStringFormat } from './../fonts/pdf-string-format';
import { PdfGraphics, _PdfTransformationMatrix, PdfBrush, PdfPen } from './../graphics/pdf-graphics';
import { PdfFontFamily, PdfStandardFont, PdfFont } from './../fonts/pdf-standard-font';
import { PdfAppearance } from './../annotations/pdf-appearance';
import { PdfFieldActions } from '../pdf-action';
import { PdfSignature } from '../security/digital-signature/signature/pdf-signature';
import { Size, Rectangle, PdfColor } from './../pdf-type';
/**
* `PdfField` class represents the base class for form field objects.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the count of the loaded field items
* let count: number = field.itemsCount;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare abstract class PdfField {
/**
* Reference to the field object in the cross-reference table.
*
* @private
*/
_ref: _PdfReference;
/**
* Underlying dictionary that stores the field entries.
*
* @private
*/
_dictionary: _PdfDictionary;
/**
* Cross-reference associated with the current document.
*
* @private
*/
_crossReference: _PdfCrossReference;
/**
* Enables grouping behavior across related widgets.
*
* @private
*/
_enableGrouping: boolean;
/**
* Indicates whether the field resides on a duplicated page.
*
* @private
*/
_isDuplicatePage: boolean;
/**
* Parent form that owns this field.
*
* @private
*/
_form: PdfForm;
/**
* Child widget references for this field.
*
* @private
*/
_kids: _PdfReference[];
/**
* Default index used to select an item.
*
* @private
*/
_defaultIndex: number;
/**
* Cache of parsed widget annotations keyed by index.
*
* @private
*/
_parsedItems: Map<number, PdfWidgetAnnotation>;
/**
* Fully qualified field name.
*
* @private
*/
_name: string;
/**
* Actual field name without incremental suffixes.
*
* @private
*/
_actualName: string;
/**
* Mapping name used for external representation.
*
* @private
*/
_mappingName: string;
/**
* Alternate text for the field.
*
* @private
*/
_alternateName: string;
/**
* Maximum allowed text length for text-entry fields.
*
* @private
*/
_maxLength: number;
/**
* Visibility setting for the form field.
*
* @private
*/
_visibility: PdfFormFieldVisibility;
/**
* Indicates whether the field is visible.
*
* @private
*/
_visible: boolean;
/**
* The page on which the field is placed.
*
* @private
*/
_page: PdfPage;
/**
* Default appearance used for text rendering in the field.
*
* @private
*/
_da: _PdfDefaultAppearance;
/**
* Field-level flags such as read-only, required, etc.
*
* @private
*/
_flags: _FieldFlag;
/**
* Indicates whether the field was loaded from an existing document.
*
* @private
*/
_isLoaded: boolean;
/**
* Indicates whether an appearance stream has been set for the field.
*
* @private
*/
_setAppearance: boolean;
/**
* String formatting applied to field text.
*
* @private
*/
_stringFormat: PdfStringFormat;
/**
* Font used for rendering the field content.
*
* @private
*/
_font: PdfFont;
/**
* Name of the font used in the field appearance.
*
* @private
*/
_fontName: string;
/**
* Gray brush used for drawing default appearances.
*
* @private
*/
_gray: PdfBrush;
/**
* Silver brush used for drawing default appearances.
*
* @private
*/
_silver: PdfBrush;
/**
* White brush used for drawing default appearances.
*
* @private
*/
_white: PdfBrush;
/**
* Black brush used for drawing default appearances.
*
* @private
*/
_black: PdfBrush;
/**
* Indicates transparent background for the field.
*
* @private
*/
_isTransparentBackColor: boolean;
/**
* Indicates transparent border for the field.
*
* @private
*/
_isTransparentBorderColor: boolean;
/**
* Tab order index for keyboard navigation.
*
* @private
*/
_tabIndex: number;
/**
* Index position of the underlying widget annotation.
*
* @private
*/
_annotationIndex: number;
/**
* Default font used for field content.
*
* @private
*/
_defaultFont: PdfStandardFont;
/**
* Font used for field appearance generation.
*
* @private
*/
_appearanceFont: PdfStandardFont;
/**
* Default font used for list item text.
*
* @private
*/
_defaultItemFont: PdfStandardFont;
/**
* Indicates whether the field should be flattened.
*
* @private
*/
_flatten: boolean;
/**
* Font used for circle caption rendering.
*
* @private
*/
_circleCaptionFont: PdfStandardFont;
/**
* Horizontal alignment of the field text.
*
* @private
*/
_textAlignment: PdfTextAlignment;
/**
* Indicates whether field updates are in progress.
*
* @private
*/
_isUpdating: boolean;
/**
* Indicates whether field data is being imported.
*
* @private
*/
_isImport: boolean;
/**
* Export value used for checkable fields.
*
* @private
*/
_exportValue: string;
/**
* Gets the count of the loaded field items (Read only).
*
* @returns {number} Items count.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the count of the loaded field items
* let count: number = field.itemsCount;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly itemsCount: number;
/**
* Gets the form object of the field (Read only).
*
* @returns {PdfForm} Form.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the form object of the field
* let form: PdfForm = field.form;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly form: PdfForm;
/**
* Gets the name of the field (Read only).
*
* @returns {string} Field name.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the name of the field
* let name: string = field.name;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly name: string;
/**
* Gets the actual name of the field (Read only).
*
* @private
* @returns {string} Actual name.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the actual name of the field
* let name: string = field.actualName;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly actualName: string;
/**
* Gets the mapping name to be used when exporting interactive form field data from the document.
*
* @returns {string} Mapping name.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the mapping name of the field
* let name: string = field.mappingName;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the mapping name to be used when exporting interactive form field data from the document.
*
* @param {string} value Mapping name.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the mapping name of the field
* field.mappingName = 'Author';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
mappingName: string;
/**
* Gets the tool tip of the form field.
*
* @returns {string} Tooltip.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the tool tip value of the field
* let toolTip: string = field.toolTip;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the tool tip of the form field.
*
* @param {string} value Tooltip.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the tool tip value of the field
* field.toolTip = 'Author of the document';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
toolTip: string;
/**
* Gets the form field visibility.
*
* @returns {PdfFormFieldVisibility} Field visibility option.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the form field visibility.
* let visibility: PdfFormFieldVisibility = field.visibility;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the form field visibility.
*
* @param {PdfFormFieldVisibility} value visibility.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the form field visibility.
* field.visibility = PdfFormFieldVisibility.visible;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
visibility: PdfFormFieldVisibility;
/**
* Gets the bounds.
*
* @returns {Rectangle} Bounds.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the bounds of list box field.
* let bounds: Rectangle = field.bounds;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the bounds.
*
* @param {Rectangle} value bounds.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the bounds.
* field.bounds = {x: 10, y: 10, width: 100, height: 20};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
bounds: Rectangle;
/**
* Gets the rotation angle of the field.
*
* @returns {number} angle.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the rotation angle of the form field.
* let rotate: number = field.rotate;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the rotation angle of the field.
*
* @param {number} value rotation angle.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the rotation angle.
* field.rotate = 90;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
rotate: number;
/**
* Gets the fore color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the fore color of the field.
* let color: PdfColor = field.color;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the fore color of the field.
*
* @param {PdfColor} value R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the fore color of the field.
* field.color = {r: 255, g: 0, b: 0};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
color: PdfColor;
/**
* Gets the background color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the background color of the field.
* let backColor: PdfColor = field.backColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the background color of the field.
*
* @param {PdfColor} value R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the background color of the field.
* field.backColor = {r: 255, g: 0, b: 0};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
backColor: PdfColor;
/**
* Gets the border color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the border color of the field.
* let borderColor: PdfColor = field.borderColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the border color of the field.
*
* @param {PdfColor} value Array with R, G, B, A color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the border color of the field.
* field.borderColor = {r: 255, g: 0, b: 0};
* // Sets the transparent border color of the field.
* field.borderColor = {r: 255, g: 255, b: 255, isTransparent: true};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
borderColor: PdfColor;
/**
* Gets a value indicating whether read only.
*
* @returns {boolean} read only or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets a value indicating whether read only.
* let readOnly: boolean = field.readOnly;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating whether read only.
*
* @param {boolean} value read only or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets a value indicating whether read only.
* field.readOnly = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readOnly: boolean;
/**
* Gets a value indicating whether the field is required.
*
* @returns {boolean} required or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets a value indicating whether the field is required.
* let required: boolean = field.required;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating whether the field is required.
*
* @param {boolean} value required or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets a value indicating whether the field is required.
* field.required = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
required: boolean;
/**
* Gets a value indicating the visibility of the field (Read only).
*
* @returns {boolean} visible or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets a value indicating the visibility of the field.
* let visible: boolean = field.visible;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating the visibility of the field.
* Only applicable for newly created PDF form fields.
*
* @param {boolean} value or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets a value indicating the visibility of the field
* field.visible = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
visible: boolean;
/**
* Gets the width, style and dash of the border of the field.
*
* @returns {PdfInteractiveBorder} Border properties.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the width, style and dash of the border of the field.
* let border: PdfInteractiveBorder = field.border;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the width, style and dash of the border of the field.
*
* @param {PdfInteractiveBorder} value Border properties.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the width, style and dash of the border of the field.
* field.border = new PdfInteractiveBorder({width: 2, style: PdfBorderStyle.solid});
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
border: PdfInteractiveBorder;
/**
* Gets the rotation of the field (Read only).
*
* @returns {PdfRotationAngle} Rotation angle.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the rotation of the field.
* let rotate: PdfRotationAngle = field.rotationAngle;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly rotationAngle: PdfRotationAngle;
/**
* Gets a value indicating whether the field is allow to export data or not.
*
* @returns {boolean} Allow to export data or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets a value indicating whether the field is allow to export data or not.
* let export: boolean = field.export;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating whether the field is allow to export data or not.
*
* @param {boolean} value Allow to export data or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets a value indicating whether the field is allow to export data or not.
* field.export = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export: boolean;
/**
* Gets the tab index of annotation in current page.
*
* @returns {number} tab index.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the tab index of annotation in current page.
* let tabIndex: number = field.tabIndex;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the tab index of a annotation in the current page.
*
* @param {number} value index.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the tab index of annotation in current page.
* field.tabIndex = 5;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
tabIndex: number;
/**
* Gets the page object of the form field (Read only).
*
* @returns {PdfPage} Page object.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the page object of the form field.
* let page: PdfPage = field.page;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly page: PdfPage;
/**
* Gets the boolean flag indicating whether the form field have been flattened or not.
*
* @returns {boolean} Flatten.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Get the first field
* let field: PdfField = document.form.fieldAt(0);
* // Gets the boolean flag indicating whether the form field have been flattened or not.
* let flatten: boolean = field.flatten;
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the boolean flag indicating whether the form field have been flattened or not.
*
* @param {boolean} value Flatten.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Get the first field
* let field: PdfField = document.form.fieldAt(0);
* // Sets the boolean flag indicating whether the form field have been flattened or not.
* field.flatten = true;
* // Destroy the document
* document.destroy();
* ```
*/
flatten: boolean;
/**
* Gets a cached gray brush or creates one when needed.
*
* @private
* @returns {PdfBrush} returns the pdfbrush
*/
readonly _grayBrush: PdfBrush;
/**
* Gets a cached silver brush or creates one when needed.
*
* @private
* @returns {PdfBrush} returns the pdfbrush
*/
readonly _silverBrush: PdfBrush;
/**
* Gets a cached white brush or creates one when needed.
*
* @private
* @returns {PdfBrush} returns the pdfbrush
*/
readonly _whiteBrush: PdfBrush;
/**
* Gets a cached black brush or creates one when needed.
*
* @private
* @returns {PdfBrush} returns the pdfbrush
*/
readonly _blackBrush: PdfBrush;
/**
* Gets the number of child items associated with the annotation.
*
* @private
* @returns {number} returns the kids count.
*/
readonly _kidsCount: number;
/**
* Indicates whether a background color is defined in the annotation or its appearance dictionary.
*
* @private
* @returns {boolean} `true` if a background color is defined; otherwise, `false`.
*/
readonly _hasBackColor: boolean;
/**
* Indicates whether a border color is defined in the annotation or its appearance dictionary.
*
* @private
* @returns {boolean} `true` if a border color is defined; otherwise, `false`.
*/
readonly _hasBorderColor: boolean;
/**
* Determines the effective background color using widget and appearance dictionaries.
*
* @private
* @param {boolean} hasTransparency is true if it has parsed backcolor.
* @returns {PdfColor} of the background.
*/
_parseBackColor(hasTransparency: boolean): PdfColor;
/**
* Determines the effective border color using widget and appearance dictionaries.
*
* @private
* @param {boolean} hasTransparency - It returns true if transparency is present.
* @returns {PdfColor} returns the pdfcolor.
*/
_parseBorderColor(hasTransparency: boolean): PdfColor;
/**
* Updates the border style width and dash entries in the appearance dictionary.
*
* @private
* @param {PdfColor} value - The background color.
* @param {boolean} hasTransparency - It returns true if transparency is present.
* @returns {void} nothing.
*/
_updateBackColor(value: PdfColor, hasTransparency?: boolean): void;
/**
* Updates the annotation border color handling transparency and appearance entries.
*
* @private
* @param {PdfColor} value - The border color to apply (RGB; may include `isTransparent`).
* @param {boolean} [hasTransparency=false] - When `true`, treats `value.isTransparent` as a request to clear border color.
* @returns {void} nothing.
*/
_updateBorderColor(value: PdfColor, hasTransparency?: boolean): void;
/**
* Gets the field item as `PdfWidgetAnnotation` at the specified index.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the loaded form field
* let field: PdfField = document.form.fieldAt(0);
* // Access the count of the field items.
* let count: number = field.count;
* // Access the first item
* let item: PdfWidgetAnnotation = field.itemAt(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {number} index Item index.
* @returns {PdfWidgetAnnotation} Loaded PDF form field item at the specified index.
*/
itemAt(index: number): PdfWidgetAnnotation;
/**
* Sets the flag to indicate the new appearance creation.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Set boolean flag to create a new appearance stream for form fields.
* document.form.fieldAt(0).setAppearance(true);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {boolean} value Set appearance.
* @returns {void} Nothing.
*/
setAppearance(value: boolean): void;
/**
* Gets the value associated with the specified key.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Gets the value associated with the key 'Author'.
* let value: string = document.form.fieldAt(0).getValue('Author');
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {string} name Key.
* @returns {string} Value associated with the key.
*/
getValue(name: string): string;
/**
* Sets the value associated with the specified key.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Set custom value
* field.setValue('Author', 'John');
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {string} name Key.
* @param {string} value Value associated with the key..
* @returns {void} Nothing.
*/
setValue(name: string, value: string): void;
/**
* Remove the form field item from the specified index.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Remove the first item of the form field
* field.removeItemAt(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {number} index Item index to remove.
* @returns {void} Nothing.
*/
removeItemAt(index: number): void;
/**
* Remove the specified form field item.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Remove the first item of the form field
* field.removeItem(field.itemAt(0));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfWidgetAnnotation} item Item to remove.
* @returns {void} Nothing.
*/
removeItem(item: PdfWidgetAnnotation): void;
/**
* Gets the resolved field flag value using inheritable properties with default fallback.
*
* @private
* @returns {_FieldFlag} The resolved field flags.
*/
/**
* Sets the field flag value and updates the field dictionary.
*
* @private
* @param {_FieldFlag} value - The new field flags to apply.
* @returns {void} nothing.
*/
_fieldFlags: _FieldFlag;
/**
* Gets the default appearance by reading the inheritable appearance string.
*
* @private
* @returns {_PdfDefaultAppearance} The default appearance if defined.
*/
readonly _defaultAppearance: _PdfDefaultAppearance;
/**
* Gets the appearance characteristics dictionary for the widget.
*
* @private
* @returns {_PdfDictionary} The appearance characteristics (MK) dictionary.
*/
readonly _mkDictionary: _PdfDictionary;
/**
* Updates the border style width and dash entries in the appearance dictionary.
*
* @private
* @param {_PdfDictionary} dictionary - The dictionary to update (usually widget or field dictionary).
* @param {PdfInteractiveBorder} value - The border settings to apply (width, style, dash).
* @returns {void} nothing.
*/
_updateBorder(dictionary: _PdfDictionary, value: PdfInteractiveBorder): void;
/**
* Performs control specific post processing optionally flattening appearance.
*
* @private
* @param {boolean} [isFlatten] - When `true`, flattens the appearance.
* @returns {void} nothing.
*/
abstract _doPostProcess(isFlatten?: boolean): void;
/**
* Returns true when the annotation flags indicate print and no view state.
*
* @private
* @param {_PdfDictionary} dictionary - The annotation/field dictionary.
* @returns {boolean} `true` if print & no-view flags are set; otherwise, `false`.
*/
_checkFieldFlag(dictionary: _PdfDictionary): boolean;
/**
* Registers the font resource and populates default appearance entries.
*
* @private
* @param {PdfFont} font - The font to register and use for appearances.
* @returns {void} nothing.
*/
_initializeFont(font: PdfFont): void;
/**
* Draws a rectangular control background, border and bevel or inset shadows.
*
* @private
* @param {PdfGraphics} g - Graphics context.
* @param {_PaintParameter} parameter - Drawing parameters.
* @returns {void} nothing.
*/
_drawRectangularControl(g: PdfGraphics, parameter: _PaintParameter): void;
/**
* Renders the control border using rectangle or underline style.
*
* @private
* @param {PdfGraphics} g - Graphics context.
* @param {Rectangle} bounds - Target bounds.
* @param {PdfPen} borderPen - Border pen.
* @param {PdfBorderStyle} style - Border style.
* @param {number} borderWidth - Border width in points.
* @returns {void} nothing.
*/
_drawBorder(g: PdfGraphics, bounds: Rectangle, borderPen: PdfPen, style: PdfBorderStyle, borderWidth: number): void;
/**
* Draws the highlight shadow along the left and top edges of the control.
*
* @private
* @param {PdfGraphics} g - Graphics context.
* @param {Rectangle} bounds - Target bounds.
* @param {number} width - Shadow width in points.
* @param {PdfBrush} brush - Shadow brush.
* @returns {void} nothing.
*/
_drawLeftTopShadow(g: PdfGraphics, bounds: Rectangle, width: number, brush: PdfBrush): void;
/**
* Draws the shadow along the right and bottom edges of the control.
*
* @private
* @param {PdfGraphics} g - Graphics context.
* @param {Rectangle} bounds - Target bounds.
* @param {number} width - Shadow width in points.
* @param {PdfBrush} brush - Shadow brush.
* @returns {void} nothing.
*/
_drawRightBottomShadow(g: PdfGraphics, bounds: Rectangle, width: number, brush: PdfBrush): void;
/**
* Paints a radio button appearance including fill, border, shadows and mark.
*
* @private
* @param {PdfGraphics} graphics - Graphics context.
* @param {_PaintParameter} parameter - Drawing parameters.
* @param {string} checkSymbol - Glyph used for the selected state.
* @param {_PdfCheckFieldState} state - Visual state to render.
* @returns {void} nothing.
*/
_drawRadioButton(graphics: PdfGraphics, parameter: _PaintParameter, checkSymbol: string, state: _PdfCheckFieldState): void;
/**
* Draws a circular border sized to the bounds and border width.
*
* @private
* @param {PdfGraphics} graphics - Graphics context.
* @param {Rectangle} bounds - Target bounds.
* @param {PdfPen} borderPen - Border pen.
* @param {number} borderWidth - Border width.
* @returns {void} nothing.
*/
_drawRoundBorder(graphics: PdfGraphics, bounds: Rectangle, borderPen: PdfPen, borderWidth: number): void;
/**
* Draws beveled or inset arc shadows around a circular control.
*
* @private
* @param {PdfGraphics} graphics - Graphics context.
* @param {_PaintParameter} parameter - Drawing parameters.
* @param {_PdfCheckFieldState} state - Visual state to render.
* @returns {void} nothing.
*/
_drawRoundShadow(graphics: PdfGraphics, parameter: _PaintParameter, state: _PdfCheckFieldState): void;
/**
* Paints a checkbox appearance including background, border, shadows and glyph.
*
* @private
* @param {PdfGraphics} graphics - Graphics context.
* @param {_PaintParameter} parameter - Drawing parameters.
* @param {string} checkSymbol - Glyph used for the selected state.
* @param {_PdfCheckFieldState} state - Visual state to render.
* @param {PdfFont} [font] - Optional font to use for glyph drawing.
* @returns {void} nothing.
*/
_drawCheckBox(graphics: PdfGraphics, parameter: _PaintParameter, checkSymbol: string, state: _PdfCheckFieldState, font?: PdfFont): void;
/**
* Adds the widget to the kids array and updates cached item mappings.
*
* @private
* @param {PdfWidgetAnnotation} item - The widget annotation to add.
* @returns {void} nothing.
*/
_addToKid(item: PdfWidgetAnnotation): void;
/**
* Draws a template on the page respecting page rotation and text mode.
*
* @private
* @param {PdfTemplate} template - The template to draw.
* @param {PdfPage} page - Target page.
* @param {{x: number, y: number, width: number, height: number}} bounds - Destination bounds. // eslint-disable-line
* @returns {void} nothing.
*/
_drawTemplate(template: PdfTemplate, page: PdfPage, bounds: {
x: number;
y: number;
width: number;
height: number;
}): void;
/**
* Appends a list option to the field and updates the options array entry.
*
* @private
* @param {PdfListFieldItem} item - The list item to append.
* @param {PdfListField} field - The target list field.
* @returns {void} nothing.
*/
_addToOptions(item: PdfListFieldItem, field: PdfListField): void;
/**
* Adds or replaces an appearance stream entry for the specified state key.
*
* @private
* @param {_PdfDictionary} dictionary - The widget or field dictionary.
* @param {PdfTemplate} template - The appearance template.
* @param {string} key - The state key (e.g., 'N', 'D', 'R', or a /Yes-like name).
* @returns {void} nothing.
*/
_addAppearance(dictionary: _PdfDictionary, template: PdfTemplate, key: string): void;
/**
* Computes the rotated rectangle for rendering text within a rotated page.
*
* @private
* @param {Rectangle} rect - Original rectangle.
* @param {Size} size - Page size.
* @param {PdfRotationAngle} angle - Page rotation angle.
* @returns {Rectangle} The rotated rectangle.
*/
_rotateTextBox(rect: Rectangle, size: Size, angle: PdfRotationAngle): Rectangle;
/**
* Validates the index is within range and throws when out of bounds.
*
* @private
* @param {number} value - Index to validate.
* @param {number} length - Valid length (upper bound).
* @returns {void} nothing.
* @throws {Error} When the index is out of range.
*/
_checkIndex(value: number, length: number): void;
/**
* Resolves the current appearance state value from the widget or field.
*
* @private
* @returns {string} The appearance state value, if any.
*/
_getAppearanceStateValue(): string;
/**
* Gets the text alignment from widget or field dictionaries with default fallback.
*
* @private
* @returns {PdfTextAlignment} The effective text alignment.
*/
_getTextAlignment(): PdfTextAlignment;
/**
* Sets the text alignment on the widget or field dictionary and updates formatting.
*
* @private
* @param {PdfTextAlignment} value - The alignment to set.
* @returns {void} nothing.
*/
_setTextAlignment(value: PdfTextAlignment): void;
/**
* Materializes and returns the widget collection for the field.
*
* @private
* @returns {PdfWidgetAnnotation[]} The materialized widget annotations.
*/
_parseItems(): PdfWidgetAnnotation[];
}
/**
* `PdfTextBoxField` class represents the text box field objects.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfTextBoxField extends PdfField {
/**
* Text content of the field.
*
* @private
*/
_text: string;
/**
* Default text value of the field.
*
* @private
*/
_defaultValue: string;
/**
* Enables spell checking for text input.
*
* @private
*/
_spellCheck: boolean;
/**
* Inserts spaces when formatting text input.
*
* @private
*/
_insertSpaces: boolean;
/**
* Enables multiline text input.
*
* @private
*/
_multiline: boolean;
/**
* Masks text input for password fields.
*
* @private
*/
_password: boolean;
/**
* Enables vertical scrolling when text exceeds bounds.
*
* @private
*/
_scrollable: boolean;
/**
* Automatically resizes text to fit the field bounds.
*
* @private
*/
_autoResizeText: boolean;
/**
* Indicates whether the text content has changed.
*
* @private
*/
_isTextChanged: boolean;
/**
* Defines JavaScript and other field-level actions.
*
* @private
*/
_actions: PdfFieldActions;
/**
* Represents a text box field of the PDF document.
*
* @private
*/
constructor();
/**
* Represents a text box field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The name of the field.
* @param {Rectangle} bounds The bounds of the field.
* ```typescript
* // 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 text box field
* let field: PdfTextBoxField = new PdfTextBoxField(page, 'FirstName', {x: 10, y: 10, width: 100, height: 50});
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle);
/**
* Represents a text box field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The unique name of the field.
* @param {Rectangle} bounds The bounds of the field.
* @param {object} [properties] Optional customization properties.
* @param {string} [properties.toolTip] Tooltip text.
* @param {PdfColor} [properties.color] Fore color (text color) of the field (RGB).
* @param {PdfColor} [properties.backColor] Background color of the field.
* @param {PdfColor} [properties.borderColor] Border color.
* @param {PdfInteractiveBorder} [properties.border] Border settings (width, style, dash).
* @param {string} [properties.text] Initial text value of the field.
* @param {PdfFont} [properties.font] Font applied to the field text.
*
* ```typescript
* // Load an existing PDF
* const document = new PdfDocument(data);
* // Gets the first page of the document
* const page = document.getPage(0);
* // Add new textbox field into PDF form
* document.form.add(new PdfTextBoxField(
* page,
* 'FirstName',
* { x: 50, y: 600, width: 200, height: 22 },
* {
* toolTip: 'Enter your first name',
* color: { r: 0, g: 0, b: 0 },
* backColor: { r: 255, g: 255, b: 255 },
* borderColor: { r: 0, g: 122, b: 204 },
* border: new PdfInteractiveBorder({width: 1, style: PdfBorderStyle.solid}),
* text: 'John',
* font: document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular)
* }
* ));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle, properties: {
toolTip?: string;
color?: PdfColor;
backColor?: PdfColor;
borderColor?: PdfColor;
border?: PdfInteractiveBorder;
text?: string;
font?: PdfFont;
});
/**
* Parse an existing text box field.
*
* @private
* @param {PdfForm} form Form object.
* @param {_PdfDictionary} dictionary Field dictionary.
* @param {_PdfCrossReference} crossReference Cross reference object.
* @param {_PdfReference} reference Field reference.
* @returns {PdfTextBoxField} Text box field.
*/
static _load(form: PdfForm, dictionary: _PdfDictionary, crossReference: _PdfCrossReference, reference: _PdfReference): PdfTextBoxField;
/**
* Gets the actions of the field. [Read-Only]
*
* @returns {PdfFieldActions} The actions.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access the text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Get the action value from the text box field.
* const PdfFieldActions: PdfFieldActions = field.actions;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly actions: PdfFieldActions;
/**
* Gets the value of the text box field.
*
* @returns {string} Text.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets the text value from text box field
* let text: string = field.text;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the value of the text box field.
*
* @param {string} value Text.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets the text value to text box field
* field.text = 'Syncfusion';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
text: string;
/**
* Gets the text alignment in a text box.
*
* @returns {PdfTextAlignment} Text alignment.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets the text alignment from text box field
* let alignment: PdfTextAlignment = field.textAlignment;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the text alignment in a text box.
*
* @param {PdfTextAlignment} value Text alignment.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets the text alignment of form field as center
* field.textAlignment = PdfTextAlignment.center;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
textAlignment: PdfTextAlignment;
/**
* Gets the default value of the field.
*
* @returns {string} Default value.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets the default value from the text box field
* let value: string = field.defaultValue;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the default value of the field.
*
* @param {string} value Default value.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets the default value of the text box field
* field.defaultValue = 'Syncfusion';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
defaultValue: string;
/**
* Gets a value indicating whether this `PdfTextBoxField` is multiline.
*
* @returns {boolean} multiline.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets a value indicating whether this `PdfTextBoxField` is multiline.
* let multiLine: boolean = field.multiLine;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating whether this `PdfTextBoxField` is multiline.
*
* @param {boolean} value multiLine or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets a value indicating whether this `PdfTextBoxField` is multiline.
* field.multiLine = false;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
multiLine: boolean;
/**
* Gets a value indicating whether this `PdfTextBoxField` is password.
*
* @returns {boolean} password.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets a value indicating whether this `PdfTextBoxField` is password.
* let password: boolean = field.password;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating whether this `PdfTextBoxField` is password.
*
* @param {boolean} value password or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets a value indicating whether this `PdfTextBoxField` is password.
* field.password = false;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
password: boolean;
/**
* Gets a value indicating whether this `PdfTextBoxField` is scrollable.
*
* @returns {boolean} scrollable.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets a value indicating whether this `PdfTextBoxField` is scrollable.
* let scrollable: boolean = field.scrollable;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating whether this `PdfTextBoxField` is scrollable.
*
* @param {boolean} value scrollable or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets a value indicating whether this `PdfTextBoxField` is scrollable.
* field.scrollable = false;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
scrollable: boolean;
/**
* Gets a value indicating whether to check spelling.
*
* @returns {boolean} spellCheck.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets a value indicating whether to check spelling
* let spellCheck: boolean = field.spellCheck;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value indicating whether to check spelling.
*
* @param {boolean} value spellCheck or not.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets a value indicating whether to check spelling
* field.spellCheck = false;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
spellCheck: boolean;
/**
* Meaningful only if the MaxLength property is set and the Multiline, Password properties are false.
* If set, the field is automatically divided into as many equally spaced positions, or combs,
* as the value of MaxLength, and the text is laid out into those combs.
*
* @returns {boolean} insertSpaces.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets a value indicating whether this `PdfTextBoxField` is insertSpaces.
* let insertSpaces: boolean = field.insertSpaces;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Meaningful only if the MaxLength property is set and the Multiline, Password properties are false.
* If set, the field is automatically divided into as many equally spaced positions, or combs,
* as the value of MaxLength, and the text is laid out into those combs.
*
* @param {boolean} value insertSpaces.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets a value indicating whether this `PdfTextBoxField` is insertSpaces.
* field.insertSpaces = false;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
insertSpaces: boolean;
/**
* Gets the highlight mode of the field.
*
* @returns {PdfHighlightMode} highlight mode.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets the highlight mode of text box field
* let mode: PdfHighlightMode = field.highlightMode;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the highlight mode of the field.
*
* @param {PdfHighlightMode} value highlight mode.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets the highlight mode of text box field as outline
* field.highlightMode = PdfHighlightMode.outline;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
highlightMode: PdfHighlightMode;
/**
* Gets the maximum length of the field, in characters.
*
* @returns {number} maximum length.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets the maximum length of the field, in characters.
* let maxLength: number = field.maxLength;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the maximum length of the field, in characters.
*
* @param {number} value maximum length.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets the maximum length of the field, in characters.
* field.maxLength = 20;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
maxLength: number;
/**
* Gets the flag indicating whether the auto resize text enabled or not.
* Note: Applicable only for newly created PDF fields.
*
* @returns {boolean} Enable or disable auto resize text.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets the flag indicating whether the auto resize text enabled or not.
* let isAutoResize: boolean = field.isAutoResizeText;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the flag indicating whether the auto resize text enabled or not.
* Note: Applicable only for newly created PDF fields.
*
* @param {boolean} value Enable or disable auto resize text.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets the flag indicating whether the auto resize text enabled or not.
* field.isAutoResizeText = false;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
isAutoResizeText: boolean;
/**
* Gets the font of the field.
*
* @returns {PdfFont} font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Gets the font of the field.
* let font: PdfFont = field.font;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the font of the field.
*
* @param {PdfFont} value font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfTextBoxField = document.form.fieldAt(0) as PdfTextBoxField;
* // Sets the font of the field
* field.font = document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.bold);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
font: PdfFont;
/**
* Gets the background color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the background color of the field.
* let backColor: PdfColor = field.backColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the background color of the field.
*
* @param {PdfColor} value Array with R, G, B, A color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the text box field at index 0
* let firstName: PdfField = document.form.fieldAt(0);
* // Sets the background color of the field.
* firstName.backColor = {r: 255, g: 0, b: 0};
* // Access the text box field at index 1
* let secondName: PdfField = document.form.fieldAt(1);
* // Sets the background color of the field to transparent.
* secondName.backColor = {r: 0, g: 0, b: 0, isTransparent: true};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
backColor: PdfColor;
/**
* Initializes the field with dictionary entries default values and widget creation.
*
* @private
* @param {PdfPage} page - The page to place the field in.
* @param {string} name - The field name.
* @param {Rectangle} bounds - The field bounds.
* @returns {void} nothing.
*/
_initialize(page: PdfPage, name: string, bounds: Rectangle): void;
/**
* Creates the widget annotation for the field and initializes appearance settings.
*
* @private
* @param {Rectangle} bounds - Widget bounds.
* @returns {void} nothing.
*/
_createItem(bounds: Rectangle): void;
/**
* Generates appearances or flattens widgets based on settings and field state.
*
* @private
* @param {boolean} [isFlatten=false] - When `true`, flattens the field appearances.
* @returns {void} nothing.
*/
_doPostProcess(isFlatten?: boolean): void;
/**
* Processes a single widget appearance or flattens it onto the page.
*
* @private
* @param {boolean} isFlatten - When `true`, flattens the appearance on page.
* @param {PdfWidgetAnnotation} [widget] - Optional widget to process; defaults to the field.
* @returns {void} nothing.
*/
_postProcess(isFlatten: boolean, widget?: PdfWidgetAnnotation): void;
/**
* Builds the appearance template for the widget including background border and text.
*
* @private
* @param {boolean} isFlatten - Whether generating for flattening.
* @param {PdfWidgetAnnotation | PdfTextBoxField} widget - The source widget/field.
* @returns {PdfTemplate} The generated appearance template.
*/
_createAppearance(isFlatten: boolean, widget: PdfWidgetAnnotation | PdfTextBoxField): PdfTemplate;
/**
* Normalizes a date value using the acrobat format pattern when possible.
*
* @private
* @param {string} textValue - The input text value.
* @param {string} afFormat - The Acrobat format pattern.
* @returns {string} The normalized value.
*/
_normalizeDateValue(textValue: string, afFormat: string): string;
/**
* Attempts to parse an unknown date value using multiple common date patterns.
*
* @private
* @param {string} text - Date text to parse.
* @returns {Date} Parsed date if valid; otherwise `undefined`.
*/
_parseUnknownDate(text: string): Date;
/**
* Formats a date using an acrobat date pattern with mapped tokens.
*
* @private
* @param {Date} date - Date to format.
* @param {string} format - Acrobat pattern.
* @returns {string} The formatted string.
*/
_formatDateUsingAcrobatFormat(date: Date, format: string): string;
/**
* Extracts an acrobat format pattern from a JavaScript format function call.
*
* @private
* @param {string} js - The JavaScript source.
* @returns {string} The extracted format pattern, if any.
*/
_tryParseAcrobatFormFormat(js: string): string;
/**
* Draws the text content of a field applying borders background alignment and rotation.
*
* @private
* @param {PdfGraphics} g - Graphics context.
* @param {_PaintParameter} parameter - Paint parameters.
* @param {string} text - Text to render.
* @param {PdfFont} font - Font to use.
* @param {PdfStringFormat} format - String format.
* @param {boolean} multiline - Whether multiline is enabled.
* @param {boolean} scroll - Whether scrolling is enabled.
* @param {number} [maxLength] - Optional maximum length for comb fields.
* @returns {void} nothing.
*/
_drawTextBox(g: PdfGraphics, parameter: _PaintParameter, text: string, font: PdfFont, format: PdfStringFormat, multiline: boolean, scroll: boolean, maxLength?: number): void;
}
/**
* `PdfButtonField` class represents the button field objects.
* ```typescript
* // 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 button field
* let field: PdfButtonField = new PdfButtonField(page , 'Button1', {x: 100, y: 40, width: 100, height: 20});
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfButtonField extends PdfField {
/**
* Label text displayed on the button.
*
* @private
*/
_text: string;
/**
* Appearance object used to render the button.
*
* @private
*/
_appearance: PdfAppearance;
/**
* Appearance object used to render the button.
*
* @private
*/
_actions: PdfFieldActions;
/**
* Represents a button field of the PDF document.
*
* @private
*/
constructor();
/**
* Represents a button box field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The name of the field.
* @param {Rectangle} bounds The bounds of the field.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Get the first page of the document
* let page: PdfPage = document.getPage(0);
* // Access the PDF form
* let form: PdfForm = document.form;
* // Create a new button field
* let field: PdfButtonField = new PdfButtonField(page , 'Button1', {x: 100, y: 40, width: 100, height: 20});
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle);
/**
* Represents a button field (push/submit/reset) of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The unique name of the field.
* @param {Rectangle} bounds The bounds of the field.
* @param {object} properties Required properties bag.
* @param {string} [properties.toolTip] Tooltip text shown by the viewer.
* @param {PdfColor} [properties.color] Fore color (caption/text color) (RGB).
* @param {PdfColor} [properties.backColor] Background color.
* @param {PdfColor} [properties.borderColor] Border color.
* @param {PdfInteractiveBorder} [properties.border] Border settings (width, style, dash).
* @param {string} [properties.text] Button caption text.
* @param {PdfHighlightMode} [properties.highlightMode] Button highlight mode on click/hover (e.g., invert, push, outline, noHighlighting).
* @param {PdfFont} [properties.font] Font applied to the caption text.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Get the first page of the document
* let page: PdfPage = document.getPage(0);
* // Add new button field into PDF form
* document.form.add(new PdfButtonField(
* page,
* 'Submit',
* { x: 50, y: 560, width: 120, height: 28 },
* {
* toolTip: 'Submit form',
* color: { r: 255, g: 255, b: 255 },
* backColor: { r: 0, g: 122, b: 204 },
* borderColor: { r: 0, g: 0, b: 0 },
* border: new PdfInteractiveBorder({width: 1, style: PdfBorderStyle.solid}),
* text: 'Submit',
* highlightMode: PdfHighlightMode.push,
* font: document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular)
* }
* ));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle, properties: {
toolTip?: string;
color?: PdfColor;
backColor?: PdfColor;
borderColor?: PdfColor;
border?: PdfInteractiveBorder;
text?: string;
highlightMode?: PdfHighlightMode;
});
/**
* Gets the actions of the field. [Read-Only]
*
* @returns {PdfFieldActions} The actions.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access button field
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Get the action value from button field
* let action: PdfAction = field.actions.mouseEnter;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly actions: PdfFieldActions;
/**
* Gets value of the text box field.
*
* @returns {string} Text.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access text box field
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Gets the text value from button field
* let text: string = field.text;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets value of the text box field.
*
* @param {string} value Text.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access button field
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Sets the text value of form field
* field.text = 'Click to submit';
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
text: string;
/**
* Gets the text alignment in a button field.
*
* @returns {PdfTextAlignment} Text alignment.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access button field
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Gets the text alignment from button field
* let alignment: PdfTextAlignment = field.textAlignment;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the text alignment in a button field.
*
* @param {PdfTextAlignment} value Text alignment.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access button field
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Sets the text alignment of form field as center
* field.textAlignment = PdfTextAlignment.center;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
textAlignment: PdfTextAlignment;
/**
* Gets the highlight mode of the field.
*
* @returns {PdfHighlightMode} highlight mode.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access button field
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Gets the highlight mode from button field
* let highlightMode: PdfHighlightMode = field. highlightMode;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the highlight mode of the field.
*
* @param {PdfHighlightMode} value highlight mode.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access button field
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Sets the highlight mode of button field as outline
* field.highlightMode = PdfHighlightMode.outline;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
highlightMode: PdfHighlightMode;
/**
* Gets the font of the field.
*
* @returns {PdfFont} font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Gets the font of the field.
* let font: PdfFont = field.font;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the font of the field.
*
* @param {PdfFont} value font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
* // Sets the font of the field
* field.font = document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.bold);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
font: PdfFont;
/**
* Gets the background color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the background color of the field.
* let backColor: PdfColor = field.backColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the background color of the field.
*
* @param {PdfColor} value Array with R, G, B, A color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the button field at index 0
* let submitButton: PdfField = document.form.fieldAt(0);
* // Sets the background color of the field.
* submitButton.backColor = {r: 255, g: 0, b: 0};
* // Access the button field at index 1
* let cancelButton: PdfField = document.form.fieldAt(1);
* // Sets the background color of the field to transparent.
* cancelButton.backColor = {r: 0, g: 0, b: 0, isTransparent: true};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
backColor: PdfColor;
/**
* Updates the appearance characteristics dictionary with the given caption text.
*
* @private
* @param {_PdfDictionary} fieldDictionary - Field or widget dictionary.
* @param {string} value - Caption text.
* @returns {void} nothing.
*/
_assignText(fieldDictionary: _PdfDictionary, value: string): void;
/**
* Parse an existing button field.
*
* @private
* @param {PdfForm} form Form object.
* @param {_PdfDictionary} dictionary Field dictionary.
* @param {_PdfCrossReference} crossReference Cross reference object.
* @param {_PdfReference} reference Field reference.
* @returns {PdfButtonField} Button field.
*/
static _load(form: PdfForm, dictionary: _PdfDictionary, crossReference: _PdfCrossReference, reference: _PdfReference): PdfButtonField;
/**
* Initializes the button field with core dictionary entries widget creation and font setup.
*
* @private
* @param {PdfPage} page - The page where the field is drawn.
* @param {string} name - The field name.
* @param {{x: number, y: number, width: number, height: number}} bounds - The field bounds.
* @returns {void} nothing.
*/
_initialize(page: PdfPage, name: string, bounds: {
x: number;
y: number;
width: number;
height: number;
}): void;
/**
* Creates the button widget initializes appearance values and registers the kid.
*
* @private
* @param {{x: number, y: number, width: number, height: number}} bounds - Widget bounds. // eslint-disable-line
* @returns {void} nothing.
*/
_createItem(bounds: {
x: number;
y: number;
width: number;
height: number;
}): void;
/**
* Builds appearances or flattens widgets based on settings and field state.
*
* @private
* @param {boolean} [isFlatten=false] - When `true`, flattens the field appearances.
* @returns {void} nothing.
*/
_doPostProcess(isFlatten?: boolean): void;
/**
* Processes one widget to load reuse or rebuild its appearance and optionally flatten.
*
* @private
* @param {boolean} isFlatten - Whether to flatten onto the page.
* @param {PdfWidgetAnnotation} [widget] - Optional widget to process; defaults to the field.
* @returns {void} nothing.
*/
_postProcess(isFlatten: boolean, widget?: PdfWidgetAnnotation): void;
/**
* Constructs the button appearance template including background border caption and shadows.
*
* @private
* @param {PdfWidgetAnnotation | PdfButtonField} widget - Source widget or field.
* @param {boolean} [isPressed=false] - Whether to render the pressed state.
* @returns {PdfTemplate} The generated appearance template.
*/
_createAppearance(widget: PdfWidgetAnnotation | PdfButtonField, isPressed?: boolean): PdfTemplate;
/**
* Draws the normal button state with background border and caption respecting rotation.
*
* @private
* @param {PdfGraphics} g - Graphics context.
* @param {_PaintParameter} parameter - Paint parameters.
* @param {string} text - Caption text.
* @param {PdfFont} font - Caption font.
* @param {PdfStringFormat} format - Caption format.
* @returns {void} nothing.
*/
_drawButton(g: PdfGraphics, parameter: _PaintParameter, text: string, font: PdfFont, format: PdfStringFormat): void;
/**
* Draws the pressed button state with adjusted fill border shadows and caption position.
*
* @private
* @param {PdfGraphics} g - Graphics context.
* @param {_PaintParameter} parameter - Paint parameters.
* @param {string} text - Caption text.
* @param {PdfFont} font - Caption font.
* @param {PdfStringFormat} format - Caption format.
* @returns {void} nothing.
*/
_drawPressedButton(g: PdfGraphics, parameter: _PaintParameter, text: string, font: PdfFont, format: PdfStringFormat): void;
}
/**
* `PdfCheckBoxField` class represents the check box field objects.
* ```typescript
* // 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 check box field
* let field: PdfCheckBoxField = new PdfCheckBoxField('CheckBox1', {x: 100, y: 40, width: 20, height: 20}, page);
* // Sets the checked flag as true.
* field.checked = true;
* // Sets the tool tip value
* field.toolTip = 'Checked';
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfCheckBoxField extends PdfField {
/**
* Map of widget index to parsed state item.
*
* @private
*/
_parsedItems: Map<number, PdfStateItem>;
/**
* Represents a check box field of the PDF document.
*
* @private
*/
constructor();
/**
* Represents a check box field of the PDF document.
*
* @param {string} name The name of the field.
* @param {Rectangle} bounds The bounds of the field.
* @param {PdfPage} page The page where the field is drawn.
* ```typescript
* // 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 check box field
* let field: PdfCheckBoxField = new PdfCheckBoxField('CheckBox1', {x: 100, y: 40, width: 20, height: 20}, page);
* // Sets the checked flag as true.
* field.checked = true;
* // Sets the tool tip value
* field.toolTip = 'Checked';
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(name: string, bounds: Rectangle, page: PdfPage);
/**
* Represents a check box field of the PDF document.
*
* @param {string} name The unique name of the field.
* @param {Rectangle} bounds The bounds of the field.
* @param {PdfPage} page The page where the field is drawn.
* @param {object} properties Required properties bag.
* @param {string} [properties.toolTip] Tooltip text shown by the viewer.
* @param {PdfColor} [properties.color] Fore color of the marker (RGB).
* @param {PdfColor} [properties.backColor] Background color.
* @param {PdfColor} [properties.borderColor] Border color.
* @param {PdfInteractiveBorder} [properties.border] Border settings (width, style, dash).
* @param {boolean} [properties.checked] Initial checked state (default: false).
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Get the first page of the document
* let page: PdfPage = document.getPage(0);
* // Add new checkbox field into PDF form
* document.form.add(new PdfCheckBoxField(
* 'AcceptTerms',
* { x: 50, y: 520, width: 14, height: 14 },
* page,
* {
* toolTip: 'Accept the terms and conditions',
* backColor: { r: 255, g: 255, b: 255 },
* borderColor: { r: 0, g: 0, b: 0 },
* border: new PdfInteractiveBorder({width: 1, style: PdfBorderStyle.solid}),
* checked: true
* }
* ));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(name: string, bounds: Rectangle, page: PdfPage, properties: {
toolTip?: string;
color?: PdfColor;
backColor?: PdfColor;
borderColor?: PdfColor;
border?: PdfInteractiveBorder;
checked?: boolean;
});
/**
* Parse an existing check box field.
*
* @private
* @param {PdfForm} form Form object.
* @param {_PdfDictionary} dictionary Field dictionary.
* @param {_PdfCrossReference} crossReference Cross reference object.
* @param {_PdfReference} reference Field reference.
* @returns {PdfCheckBoxField} Check box field.
*/
static _load(form: PdfForm, dictionary: _PdfDictionary, crossReference: _PdfCrossReference, reference: _PdfReference): PdfCheckBoxField;
/**
* Gets the item at the specified index.
*
* ```typescript
* // 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;
* // Access the check box field
* let field: PdfCheckBoxField = form.fieldAt(0) as PdfCheckBoxField;
* // Gets the first list item.
* let item: PdfStateItem = field.itemAt(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {number} index Index of the field item.
* @returns {PdfStateItem} Field item at the index.
*/
itemAt(index: number): PdfStateItem;
/**
* Gets the font of the field.
*
* @returns {PdfFont} font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfCheckBoxField = document.form.fieldAt(0) as PdfCheckBoxField;
* // Gets the font of the field.
* let font: PdfFont = field.font;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the font of the field.
*
* @param {PdfFont} value font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfCheckBoxField = document.form.fieldAt(0) as PdfCheckBoxField;
* // Sets the font of the field
* field.font = document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.bold);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
font: PdfFont;
/**
* Gets the flag indicating whether the field is checked or not.
*
* @returns {boolean} Checked.
* ```typescript
* // 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;
* // Access the check box field
* let field: PdfCheckBoxField = form.fieldAt(0) as PdfCheckBoxField;
* // Gets the flag indicating whether the field is checked or not.
* let checked: Boolean = field.checked;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the flag indicating whether the field is checked or not.
*
* @param {boolean} value Checked.
* ```typescript
* // 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;
* // Access the check box field
* let field: PdfCheckBoxField = form.fieldAt(0) as PdfCheckBoxField;
* // Sets the flag indicating whether the field is checked or not.
* field.checked = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
checked: boolean;
/**
* Gets the export value of the check box field.
*
* @returns {boolean} Checked.
* ```typescript
* // 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;
* // Access the check box field
* let field: PdfCheckBoxField = form.fieldAt(0) as PdfCheckBoxField;
* // Gets the export value of the checkbox field.
* let value: string = field.exportValue;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the export value of the check box field.
*
* @param {boolean} value Checked.
* ```typescript
* // 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;
* // Access the check box field
* let field: PdfCheckBoxField = form.fieldAt(0) as PdfCheckBoxField;
* // Sets the export value.
* field.exportValue = 'Value';
* // Set the chexk box field as checked
* field.checked = true;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
exportValue: string;
/**
* Gets the text alignment in a check box field.
*
* @returns {PdfTextAlignment} Text alignment.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access check box field
* let field: PdfCheckBoxField = document.form.fieldAt(0) as PdfCheckBoxField;
* // Gets the text alignment from check box field
* let alignment: PdfTextAlignment = field.textAlignment;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the text alignment in a check box field.
*
* @param {PdfTextAlignment} value Text alignment.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access check box field
* let field: PdfCheckBoxField = document.form.fieldAt(0) as PdfCheckBoxField;
* // Sets the text alignment of form field as center
* field.textAlignment = PdfTextAlignment.center;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
textAlignment: PdfTextAlignment;
/**
* Gets the background color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the background color of the field.
* let backColor: PdfColor = field.backColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the background color of the field.
*
* @param {PdfColor} value Array with R, G, B, A color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the check box field at index 0
* let checkBox1: PdfField = document.form.fieldAt(0);
* // Sets the background color of the field.
* checkBox1.backColor = {r: 255, g: 0, b: 0};
* // Access the check box field at index 1
* let checkBox2: PdfField = document.form.fieldAt(1);
* // Sets the background color of the field to transparent.
* checkBox2.backColor = {r: 0, g: 0, b: 0, isTransparent: true};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
backColor: PdfColor;
/**
* Gets the border color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the border color of the field.
* let borderColor: PdfColor = field.borderColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the border color of the field.
*
* @param {PdfColor} value Array with R, G, B, A color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the border color of the field.
* field.borderColor = {r: 255, g: 0, b: 0};
* // Sets the background color of the field to transparent.
* field.backColor = {r: 0, g: 0, b: 0, isTransparent: true};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
borderColor: PdfColor;
/**
* Initializes the checkbox field with core dictionary entries and widget creation.
*
* @private
* @param {PdfPage} page - The page where the field is placed.
* @param {string} name - The field name.
* @param {Rectangle} bounds - The field bounds.
* @returns {void} nothing.
*/
_initialize(page: PdfPage, name: string, bounds: Rectangle): void;
/**
* Creates the checkbox widget, sets default appearance, and registers the kid.
*
* @private
* @param {Rectangle} bounds - The widget bounds.
* @returns {void} nothing.
*/
_createItem(bounds: Rectangle): void;
/**
* Builds appearances or flattens each widget based on state and settings.
*
* @private
* @param {boolean} [isFlatten=false] - When `true`, flattens the widget appearance onto the page.
* @returns {void} nothing.
*/
_doPostProcess(isFlatten?: boolean): void;
/**
* Constructs the checkbox appearance template including background, border, and mark.
*
* @private
* @param {PdfStateItem} widget - The widget to build the appearance for.
* @param {_PdfCheckFieldState} state - The check state to render.
* @returns {PdfTemplate} The generated appearance template.
*/
_createAppearance(widget: PdfStateItem, state: _PdfCheckFieldState): PdfTemplate;
/**
* Writes the normal and pressed appearance streams for a widget's state values.
*
* @private
* @param {PdfStateItem} item - The widget state item whose appearance will be created/updated.
* @param {string} [itemValue] - Optional on-state name to use (defaults to "Yes" when not provided).
* @returns {void} nothing.
*/
_drawAppearance(item: PdfStateItem, itemValue?: string): void;
}
/**
* `PdfRadioButtonListField` class represents the radio button field objects.
* ```typescript
* // 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 radio button list field
* let field: PdfRadioButtonListField = new PdfRadioButtonListField(page, 'Age');
* // Create and add first item
* let first: PdfRadioButtonListItem = field.add('1-9', {x: 100, y: 140, width: 20, height: 20});
* // Create and add second item
* let second: PdfRadioButtonListItem = new PdfRadioButtonListItem('10-49', {x: 100, y: 170, width: 20, height: 20}, page);
* field.add(second);
* // Sets selected index of the radio button list field
* field.selectedIndex = 0;
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfRadioButtonListField extends PdfField {
/**
* Map of widget index to parsed radio button item.
*
* @private
*/
_parsedItems: Map<number, PdfRadioButtonListItem>;
/**
* Selected radio item index, or -1 if none.
*
* @private
*/
_selectedIndex: number;
/**
* Indicates whether selection is required by the user.
*
* @private
*/
_isUserRequired: boolean;
/**
* Allows selecting all items in unison.
*
* @private
*/
_allowUnisonSelection: boolean;
/**
* Indicates whether duplicate widgets exist for this field.
*
* @private
*/
_hasDuplicates: boolean;
/**
* Represents a radio button list field of the PDF document.
*
* @private
*/
constructor();
/**
* Represents a radio button list field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The name of the field.
* ```typescript
* // 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 radio button list field
* let field: PdfRadioButtonListField = new PdfRadioButtonListField(page, 'Age');
* // Create and add first item
* let first: PdfRadioButtonListItem = field.add('1-9', {x: 100, y: 140, width: 20, height: 20});
* // Create and add second item
* let second: PdfRadioButtonListItem = new PdfRadioButtonListItem('10-49', {x: 100, y: 170, width: 20, height: 20}, page);
* field.add(second);
* // Sets selected index of the radio button list field
* field.selectedIndex = 0;
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string);
/**
* Represents a radio button list field (group of mutually exclusive options).
*
* @param {PdfPage} page The page where the field dictionary is created.
* @param {string} name The unique name of the field.
* @param {object} properties Required properties bag.
* @param {{name: string, bounds: Rectangle}[]} properties.items Radio button items to create (each with a name/value and bounds).
* @param {string} [properties.toolTip] Tooltip text shown by the viewer.
* @param {PdfColor} [properties.color] Fore color of the marker (RGB).
* @param {PdfColor} [properties.backColor] Background color for items.
* @param {PdfColor} [properties.borderColor] Border color for items.
* @param {PdfInteractiveBorder} [properties.border] Border settings for items (width, style, dash).
* @param {number} [properties.selectedIndex] Zero-based selected index (default: 0).
* @param {boolean} [properties.allowUnisonSelection] When true, allows the group selection to synchronize across widgets with the same value (if supported).
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Get the first page of the document
* let page: PdfPage = document.getPage(0);
* // Add new radio button list field into PDF form
* document.form.add(new PdfRadioButtonListField(
* page,
* 'AgeGroup',
* {
* items: [
* { name: '18-25', bounds: { x: 50, y: 480, width: 14, height: 14 } },
* { name: '26-35', bounds: { x: 50, y: 460, width: 14, height: 14 } },
* { name: '36-45', bounds: { x: 50, y: 440, width: 14, height: 14 } }
* ],
* toolTip: 'Select an age range',
* selectedIndex: 1,
* allowUnisonSelection: false
* }
* ));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, properties: {
items: {
name: string;
bounds: Rectangle;
}[];
toolTip?: string;
color?: PdfColor;
backColor?: PdfColor;
borderColor?: PdfColor;
border?: PdfInteractiveBorder;
selectedIndex?: number;
allowUnisonSelection?: boolean;
});
/**
* Parse an existing radio button list field.
*
* @private
* @param {PdfForm} form Form object.
* @param {_PdfDictionary} dictionary Field dictionary.
* @param {_PdfCrossReference} crossReference Cross reference object.
* @param {_PdfReference} reference Field reference.
* @returns {PdfRadioButtonListField} Radio button list field.
*/
static _load(form: PdfForm, dictionary: _PdfDictionary, crossReference: _PdfCrossReference, reference: _PdfReference): PdfRadioButtonListField;
/**
* Gets the flag indicating whether the field is checked or not (Read only).
*
* @returns {boolean} Checked.
* ```typescript
* // 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;
* // Access the radio button list field
* let field: PdfRadioButtonListField = form.fieldAt(0) as PdfRadioButtonListField;
* // Gets the flag indicating whether the field is checked or not.
* let checked: boolean = field.checked;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly checked: boolean;
/**
* Gets the selected item index.
*
* @returns {number} Index.
* ```typescript
* // 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;
* // Access the radio button list field
* let field: PdfRadioButtonListField = form.fieldAt(0) as PdfRadioButtonListField;
* // Gets the selected index.
* let index: number = field.selectedIndex;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the selected item index.
*
* @param {number} value Selected index.
* ```typescript
* // 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 radio button list field
* let field: PdfRadioButtonListField = new PdfRadioButtonListField(page, 'Age');
* // Create and add first item
* let first: PdfRadioButtonListItem = field.add('1-9', {x: 100, y: 140, width: 20, height: 20});
* // Create and add second item
* let second: PdfRadioButtonListItem = new PdfRadioButtonListItem('10-49', {x: 100, y: 170, width: 20, height: 20}, page);
* field.add(second);
* // Sets selected index of the radio button list field
* field.selectedIndex = 0;
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
selectedIndex: number;
/**
* Determines whether the radio button list contains any duplicate item values.
* Scans the current items and reports if any `value` occurs more than once.
*
* @private
* @returns {boolean} Returns `true` if at least one item `value` is duplicated; otherwise, `false`.
*/
_hasDuplicateItems(): boolean;
/**
* Gets a value that specifies whether multiple radio buttons in the same group can be selected simultaneously within the form.
*
* @returns {boolean} Indicates if unison selection is enabled.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access the form
* let form: PdfForm = document.form;
* // Gets the value indicating if unison selection is enabled
* let isUnisonSelectionEnabled: boolean = form.allowUnisonSelection;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets a value that specifies whether multiple radio buttons in the same group can be selected simultaneously within the form.
*
* @param {boolean} value Enable or disable unison selection. The default value is false.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access the form
* let form: PdfForm = document.form;
* // Disable the unison selection.
* form.allowUnisonSelection = false;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
allowUnisonSelection: boolean;
/**
* Gets the border color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the border color of the field.
* let borderColor: PdfColor = field.borderColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the border color of the field.
*
* @param {PdfColor} value Array with R, G, B, A color values in between 0 to 255.
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Sets the border color of the field.
* field.borderColor = {r: 255, g: 0, b: 0};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
borderColor: PdfColor;
/**
* Gets the item at the specified index.
*
* ```typescript
* // 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;
* // Access the radio button list field
* let field: PdfRadioButtonListField = form.fieldAt(0) as PdfRadioButtonListField;
* // Gets the first list item.
* let item: PdfRadioButtonListField = field.itemAt(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {number} index Index of the field item.
* @returns {PdfRadioButtonListItem} Field item at the index.
*/
itemAt(index: number): PdfRadioButtonListItem;
/**
* Add list item to the field.
*
* ```typescript
* // 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 radio button list field
* let field: PdfRadioButtonListField = new PdfRadioButtonListField(page, 'Age');
* // Create and add first item
* let first: PdfRadioButtonListItem = field.add('1-9', {x: 100, y: 140, width: 20, height: 20});
* // Create and add second item
* let second: PdfRadioButtonListItem = new PdfRadioButtonListItem('10-49', {x: 100, y: 170, width: 20, height: 20}, page);
* Add list item to the field
* field.add(second);
* // Sets selected index of the radio button list field
* field.selectedIndex = 0;
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfRadioButtonListItem} item List item.
* @returns {number} Index of the added item.
*/
add(item: PdfRadioButtonListItem): number;
/**
* Add list item to the field.
*
* ```typescript
* // 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 radio button list field
* let field: PdfRadioButtonListField = new PdfRadioButtonListField(page, 'Age');
* // Create and add first item
* let first: PdfRadioButtonListItem = field.add('1-9', {x: 100, y: 140, width: 20, height: 20});
* // Create and add second item
* let second: PdfRadioButtonListItem = new PdfRadioButtonListItem('10-49', {x: 100, y: 170, width: 20, height: 20}, page);
* Add list item to the field
* field.add(second);
* // Sets selected index of the radio button list field
* field.selectedIndex = 0;
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {string} value Name of the list item.
* @param {Rectangle} bounds Bounds of the list item.
* @returns {PdfRadioButtonListItem} Added item.
*/
add(value: string, bounds: Rectangle): PdfRadioButtonListItem;
/**
* Remove the radio button list item from the specified index.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Remove the first item of the form field
* field.removeItemAt(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {number} index Item index to remove.
* @returns {void} Nothing.
*/
removeItemAt(index: number): void;
/**
* Remove the specified radio button list field item.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Remove the first item of the form field
* field.removeItem(field.itemAt(0));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfRadioButtonListItem} item Item to remove.
* @returns {void} Nothing.
*/
removeItem(item: PdfRadioButtonListItem): void;
/**
* Initializes the radio button field on the specified page with the given name,
* creating its dictionary, reference, and default flags.
*
* @private
* @param {PdfPage} page The page on which the field is initialized.
* @param {string} name The field name to assign to the radio button group.
* @returns {void}
*/
_initialize(page: PdfPage, name: string): void;
/**
* Extracts and assigns option values from the field dictionary's `Opt` entry
* to corresponding radio button items, if present.
*
* @private
* @returns {void}
*/
_retrieveOptionValue(): void;
/**
* Determines the selected radio button index by inspecting inherited field value (`V`)
* and the item's appearance state (`AS`), ignoring the `Off` state.
*
* @private
* @returns {number} Returns the zero-based index of the selected item, or `-1` if none is selected.
*/
_obtainSelectedIndex(): number;
/**
* Finalizes item appearances and dictionary updates after selection changes or load,
* optionally flattening the field to static content.
*
* @private
* @param {boolean} [isFlatten=false] When `true`, draws static appearances and prevents further updates.
* @returns {void}
*/
_doPostProcess(isFlatten?: boolean): void;
/**
* Builds a visual appearance template for a radio button item based on the specified state,
* applying border, background, color, rotation, and style.
*
* @private
* @param {PdfRadioButtonListItem} widget The radio button item for which to create the appearance.
* @param {_PdfCheckFieldState} state The visual state to render (e.g., checked, unchecked, pressed).
* @returns {PdfTemplate} The generated appearance template for the requested state.
*/
_createAppearance(widget: PdfRadioButtonListItem, state: _PdfCheckFieldState): PdfTemplate;
/**
* Updates the item's appearance streams (`AP`) for normal (`N`) and pressed (`D`) states,
* generating and wiring templates for the actual value and `Off`.
*
* @private
* @param {PdfRadioButtonListItem} item The radio button item whose appearance is to be updated.
* @returns {void}
*/
_drawAppearance(item: PdfRadioButtonListItem): void;
}
/**
* Represents the base class for list box and combo box fields.
*
* ```typescript
* // 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;
* // Access the combo box field
* let comboBoxField: PdfListField = form.fieldAt(0) as PdfListField;
* // Gets the count of the loaded combo box field items.
* let comboItemsCount: number = comboBoxField.itemsCount;
* // Access the list box field
* let listBoxField: PdfListField = form.fieldAt(1) as PdfListField;
* // Gets the count of the loaded list box field items.
* let ListItemsCount: number = listBoxField.itemsCount;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare abstract class PdfListField extends PdfField {
/**
* Display text/value pairs for the list items.
*
* @private
*/
_optionArray: Array<string[]>;
/**
* Map of widget index to parsed list field item.
*
* @private
*/
_parsedItems: Map<number, PdfListFieldItem>;
/**
* Array of selected list values.
*
* @private
*/
_listValues: string[];
/**
* Index of the selected item (single select mode).
*
* @private
*/
_selectedIndex: number;
/**
* Enables multi select for the list field.
*
* @private
*/
_multiSelect: boolean;
/**
* Enables text editing in the list field.
*
* @private
*/
_editable: boolean;
/**
* Primary widget annotation for the list field.
*
* @private
*/
_widgetAnnot: PdfWidgetAnnotation;
/**
* Bounds of the list field widget.
*
* @private
*/
_bounds: {
x: number;
y: number;
width: number;
height: number;
};
/**
* Gets the count of the loaded field items (Read only).
*
* @returns {number} Items count.
* ```typescript
* // 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;
* // Access the combo box field
* let comboBoxField: PdfComboBoxField = form.fieldAt(0) as PdfComboBoxField;
* // Gets the count of the loaded combo box field items.
* let comboItemsCount: number = comboBoxField.itemsCount;
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(1) as PdfListBoxField;
* // Gets the count of the loaded list box field items.
* let ListItemsCount: number = listBoxField.itemsCount;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
readonly itemsCount: number;
/**
* Gets the bounds.
*
* @returns {Rectangle} Bounds.
* ```typescript
* // 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;
* // Access the combo box field
* let comboBoxField: PdfComboBoxField = form.fieldAt(0) as PdfComboBoxField;
* // Gets the bounds of combo box field.
* let comboBoxBounds: Rectangle = comboBoxField.bounds;
* // Access the combo box field
* let listBoxField: PdfListBoxField = form.fieldAt(1) as PdfListBoxField;
* // Gets the bounds of list box field.
* let listBoxBounds: Rectangle = listBoxField.bounds;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the bounds.
*
* @param {Rectangle} value bounds.
* ```typescript
* // 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;
* // Access the combo box field
* let comboBoxField: PdfComboBoxField = form.fieldAt(0) as PdfComboBoxField;
* // Sets the bounds of combo box field.
* comboBoxField.bounds = {x: 10, y: 10, width: 100, height: 30};
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(1) as PdfListBoxField;
* // Sets the bounds of list box field.
* listBoxField.bounds = {x: 10, y: 50, width: 100, height: 30};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
bounds: Rectangle;
/**
* Gets the selected item index or indexes.
*
* @returns {number | number[]} Index.
* ```typescript
* // 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;
* // Access the combo box field
* let comboBoxfield: PdfComboBoxField = form.fieldAt(0) as PdfComboBoxField;
* // Gets the selected item index or indexes from combo box field.
* let comboBoxIndex: number = comboBoxfield.selectedIndex;
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(1) as PdfListBoxField;
* // Gets the selected item index or indexes from list box field.
* let listBoxIndex: number = listBoxField.selectedIndex;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the selected item index or indexes.
*
* @param {number | number[]} value Selected index.
* ```typescript
* // 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 list box field
* let listField: PdfListField = new PdfListBoxField(page, 'list1', {x: 100, y: 60, width: 100, height: 50});
* // Add list items to the field.
* listField.addItem(new PdfListFieldItem('English', 'English'));
* listField.addItem(new PdfListFieldItem('French', 'French'));
* listField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* listField.selectedIndex = 2;
* // Sets the flag indicates whether the list box allows multiple selections.
* listField.multiSelect = true;
* // Add the field into PDF form
* form.add(listField);
* // Create a new combo box field
* let comboField: PdfComboBoxField = new PdfComboBoxField(page, 'list1', {x: 100, y: 160, width: 100, height: 50});
* // Add list items to the field.
* comboField.addItem(new PdfListFieldItem('English', 'English'));
* comboField.addItem(new PdfListFieldItem('French', 'French'));
* comboField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* comboField.selectedIndex = 2;
* // Sets the flag indicates whether the combo box allows multiple selections.
* comboField.multiSelect = true;
* // Add the field into PDF form
* form.add(comboField);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
selectedIndex: number | number[];
/**
* Gets the selected item value or values.
*
* @returns {string | string[]} Selected values.
* ```typescript
* // 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;
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(0) as PdfListBoxField;
* // Gets the selected item value or values from list box field.
* if (listBoxField.multiSelect) {
* let listBoxValues: string[]; = listBoxField.selectedValue;
* } else {
* let listBoxValues: string = listBoxField.selectedValue;
* }
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the selected item value or values.
*
* @param {string | string[]} value Selected values.
* ```typescript
* // 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 list box field
* let listField: PdfListField = new PdfListBoxField(page, 'list1', {x: 100, y: 60, width: 100, height: 50});
* // Add list items to the field.
* listField.addItem(new PdfListFieldItem('English', 'English'));
* listField.addItem(new PdfListFieldItem('French', 'French'));
* listField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the flag indicates whether the list box allows multiple selections.
* listField.multiSelect = true;
* // Sets the selected values
* listField.selectedValue = ['English', 'German'];
* // Add the field into PDF form
* form.add(listField);
* // Create a new combo box field
* let comboField: PdfComboBoxField = new PdfComboBoxField(page, 'list1', {x: 100, y: 160, width: 100, height: 50});
* // Add list items to the field.
* comboField.addItem(new PdfListFieldItem('English', 'English'));
* comboField.addItem(new PdfListFieldItem('French', 'French'));
* comboField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected value
* comboField.selectedValue = ['French'];
* // Add the field into PDF form
* form.add(comboField);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
selectedValue: string | string[];
/**
* Gets the flag indicates whether the list field allows multiple selections.
*
* @returns {boolean} Value indicates whether the list field allows multiple selections.
* ```typescript
* // 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;
* // Access the combo box field
* let comboBoxField: PdfComboBoxField = form.fieldAt(0) as PdfComboBoxField;
* // Gets the flag indicates whether the combo box allows multiple selections.
* let comboBoxFlag: Boolean = comboBoxField.multiSelect;
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(1) as PdfListBoxField;
* // Gets the flag indicates whether the list box allows multiple selections.
* let listBoxFlag: boolean = listBoxField.multiSelect;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the flag indicates whether the list field allows multiple selections.
*
* @param {boolean} value Indicates whether the list field allows multiple selections.
* ```typescript
* // 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 list box field
* let listField: PdfListField = new PdfListBoxField(page, 'list1', {x: 100, y: 60, width: 100, height: 50});
* // Add list items to the field.
* listField.addItem(new PdfListFieldItem('English', 'English'));
* listField.addItem(new PdfListFieldItem('French', 'French'));
* listField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* listField.selectedIndex = 2;
* // Sets the flag indicates whether the list box allows multiple selections.
* listField.multiSelect = true;
* // Add the field into PDF form
* form.add(listField);
* // Create a new combo box field
* let comboField: PdfComboBoxField = new PdfComboBoxField(page, 'list1', {x: 100, y: 160, width: 100, height: 50});
* // Add list items to the field.
* comboField.addItem(new PdfListFieldItem('English', 'English'));
* comboField.addItem(new PdfListFieldItem('French', 'French'));
* comboField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* comboField.selectedIndex = 2;
* // Sets the flag indicates whether the combo box allows multiple selections.
* comboField.multiSelect = true;
* // Add the field into PDF form
* form.add(comboField);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
multiSelect: boolean;
/**
* Gets the flag indicates whether the list field is editable.
*
* @returns {boolean} Value indicates whether the list field is editable.
* ```typescript
* // 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;
* // Access the combo box field
* let comboBoxField: PdfComboBoxField = form.fieldAt(0) as PdfComboBoxField;
* // Gets the flag indicates whether the combo box is editable.
* let comboBoxFlag: Boolean = comboBoxField.editable;
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(1) as PdfListBoxField;
* // Gets the flag indicates whether the list box is editable.
* let listBoxFlag: boolean = listBoxField.editable;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the flag indicates whether the list field is editable.
*
* @param {boolean} value Indicates whether the list field is editable.
* ```typescript
* // 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 list box field
* let listField: PdfListField = new PdfListBoxField(page, 'list1', {x: 100, y: 60, width: 100, height: 50});
* // Add list items to the field.
* listField.addItem(new PdfListFieldItem('English', 'English'));
* listField.addItem(new PdfListFieldItem('French', 'French'));
* listField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* listField.selectedIndex = 2;
* // Sets the flag indicates whether the list box is editable.
* listField.editable = true;
* // Add the field into PDF form
* form.add(listField);
* // Create a new combo box field
* let comboField: PdfComboBoxField = new PdfComboBoxField(page, 'list1', {x: 100, y: 160, width: 100, height: 50});
* // Add list items to the field.
* comboField.addItem(new PdfListFieldItem('English', 'English'));
* comboField.addItem(new PdfListFieldItem('French', 'French'));
* comboField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* comboField.selectedIndex = 2;
* // Sets the flag indicates whether the combo box is editable.
* comboField.editable = true;
* // Add the field into PDF form
* form.add(comboField);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
editable: boolean;
/**
* Gets the font of the field.
*
* @returns {PdfFont} font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfListBoxField = document.form.fieldAt(0) as PdfListBoxField;
* // Gets the font of the field.
* let font: PdfFont = field.font;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the font of the field.
*
* @param {PdfFont} value font.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfListBoxField = document.form.fieldAt(0) as PdfListBoxField;
* // Sets the font of the field
* field.font = document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.bold);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
font: PdfFont;
/**
* Gets the text alignment in a combo box field.
*
* @returns {PdfTextAlignment} Text alignment.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access combo box field
* let field: PdfComboBoxField = document.form.fieldAt(0) as PdfComboBoxField;
* // Gets the text alignment from combo box field
* let alignment: PdfTextAlignment = field.textAlignment;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the text alignment in a combo box field.
*
* @param {PdfTextAlignment} value Text alignment.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access combo box field
* let field: PdfComboBoxField = document.form.fieldAt(0) as PdfComboBoxField;
* // Sets the text alignment of form field as center
* field.textAlignment = PdfTextAlignment.center;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
textAlignment: PdfTextAlignment;
/**
* Gets the background color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the background color of the field.
* let backColor: PdfColor = field.backColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the background color of the field.
*
* @param {PdfColor} value Array with R, G, B, A color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the list field at index 0
* let list1: PdfField = document.form.fieldAt(0);
* // Sets the background color of the field.
* list1.backColor = {r: 255, g: 0, b: 0};
* // Access the list field at index 1
* let list2: PdfField = document.form.fieldAt(1);
* // Sets the background color of the field to transparent.
* list2.backColor = {r: 0, g: 0, b: 0, isTransparent: true};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
backColor: PdfColor;
/**
* Gets the option entries (`Opt`) for the radio button field, initializing the
* underlying array in the field dictionary if it does not already exist.
*
* @private
* @returns {Array<string[]>} The array of option entries associated with the field.
*/
readonly _options: Array<string[]>;
/**
* Gets the item at the specified index.
*
* ```typescript
* // 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;
* // Access the list box field
* let listBox: PdfListBoxField = form.fieldAt(0) as PdfListBoxField;
* // Gets the first list item.
* let listBoxItem: PdfListFieldItem = listBox.itemAt(0);
* // Access the combo box field
* let comboBox: PdfComboBoxField = form.fieldAt(1) as PdfComboBoxField;
* // Gets the first list item.
* let comboBoxItem: PdfListFieldItem = comboBox.itemAt(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {number} index Index of the field item.
* @returns {PdfListFieldItem} Field item at the index.
*/
itemAt(index: number): PdfListFieldItem;
/**
* Add list item.
*
* ```typescript
* // 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 list box field
* let listField: PdfListField = new PdfListBoxField(page, 'list1', {x: 100, y: 60, width: 100, height: 50});
* // Add list items to the field.
* listField.addItem(new PdfListFieldItem('English', 'English'));
* listField.addItem(new PdfListFieldItem('French', 'French'));
* listField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* listField.selectedIndex = 2;
* // Sets the flag indicates whether the list box allows multiple selections.
* listField.multiSelect = true;
* // Add the field into PDF form
* form.add(listField);
* // Create a new combo box field
* let comboField: PdfComboBoxField = new PdfComboBoxField(page, 'list1', {x: 100, y: 160, width: 100, height: 50});
* // Add list items to the field.
* comboField.addItem(new PdfListFieldItem('English', 'English'));
* comboField.addItem(new PdfListFieldItem('French', 'French'));
* comboField.addItem(new PdfListFieldItem('German', 'German'));
* // Sets the selected index
* comboField.selectedIndex = 2;
* // Sets the flag indicates whether the combo box allows multiple selections.
* comboField.multiSelect = true;
* // Add the field into PDF form
* form.add(comboField);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfListFieldItem} item Item to add.
* @returns {number} Index of the field item.
*/
addItem(item: PdfListFieldItem): number;
/**
* Remove the list item from the specified index.
*
* ```typescript
* // 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;
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(0) as PdfListBoxField;
* // Remove the list item from the list box field
* listBoxField.removeItemAt(1);
* // Access the combo box field
* let comboBoxField: PdfComboBoxField = form.fieldAt(1) as PdfComboBoxField;
* // Remove the list item from the combo box field
* comboBoxField.removeItemAt(0);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {number} index Item index to remove.
* @returns {void} Nothing.
*/
removeItemAt(index: number): void;
/**
* Remove the list item.
*
* ```typescript
* // 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;
* // Access the list box field
* let listBoxField: PdfListBoxField = form.fieldAt(0) as PdfListBoxField;
* // Remove the list item from the list box field
* listBoxField.removeItem(listBoxField.itemAt(1));
* // Access the combo box field
* let comboBoxField: PdfComboBoxField = form.fieldAt(1) as PdfComboBoxField;
* // Remove the list item from the combo box field
* comboBoxField.removeItem(comboBoxField.itemAt(0));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfListFieldItem} item Item to remove.
* @returns {void} Nothing.
*/
removeItem(item: PdfListFieldItem): void;
/**
* Initializes the list/choice field on the specified page with the given name and bounds,
* creating its dictionary, reference, kids collection, and a default widget.
*
* @private
* @param {PdfPage} page The page on which the field is initialized.
* @param {string} name The field name to assign to the list/choice field.
* @param {{x: number, y: number, width: number, height: number}} bounds The field bounds in page coordinates. // eslint-disable-line
* @returns {void}
*/
_initialize(page: PdfPage, name: string, bounds: {
x: number;
y: number;
width: number;
height: number;
}): void;
/**
* Computes the font height for the specified font family, used when the effective
* font size needs to be derived (e.g., when size is `0`).
*
* @private
* @param {PdfFontFamily} font The font family for which to compute the height.
* @returns {number} The resolved font height in points.
*/
abstract _getFontHeight(font: PdfFontFamily): number;
/**
* Creates the appearance template for the list/choice field or for a specific widget item,
* applying the current style, colors, and layout.
*
* @private
* @param {PdfListFieldItem} [item] The specific widget item to render; when omitted, renders the field appearance.
* @returns {PdfTemplate} The generated appearance template.
*/
abstract _createAppearance(item?: PdfListFieldItem): PdfTemplate;
/**
* Resolves and returns the effective font for the field or a specific item by inspecting
* style entries (`DS`) or default appearance (`DA`), and, if needed, loads an embedded font
* from document resources.
*
* @private
* @param {PdfListFieldItem} [item] The item whose font should be resolved; when omitted, resolves at the field level.
* @returns {PdfFont} The resolved PDF font instance.
*/
_obtainFont(item?: PdfListFieldItem): PdfFont;
/**
* Retrieves the selected export value(s) for the list/choice field, preferring the `V`
* entry and falling back to the index array `I` mapped through the field `Opt` entries.
*
* @private
* @returns {string[]} An array of selected export values; returns an empty array if none.
*/
_obtainSelectedValue(): string[];
/**
* Finalizes appearances for the field and its widgets, generating or attaching templates
* and optionally flattening the content into the page.
*
* @private
* @param {boolean} [isFlatten=false] When `true`, draws static appearances onto pages and prevents further updates.
* @returns {void}
*/
_doPostProcess(isFlatten?: boolean): void;
/**
* Looks up the zero-based option index whose export value matches the specified value.
*
* @private
* @param {string} value The export value to search for within the field options.
* @returns {number} The matching option index, or `-1` if not found.
*/
_tryGetIndex(value: string): number;
/**
* Adds a default widget annotation to the field with initial appearance-related entries,
* including `MK`, border/background colors, and a default `DA`.
*
* @private
* @returns {void}
*/
_addEmptyWidget(): void;
/**
* Builds the string format for text layout based on field flags (e.g., multiline)
* and the widget's justification (`Q`) entry.
*
* @private
* @returns {PdfStringFormat} The configured string format including alignment settings.
*/
_getStringFormat(): PdfStringFormat;
}
/**
* `PdfComboBoxField` class represents the combo box field objects.
* ```typescript
* // 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();
* ```
*/
export declare class PdfComboBoxField extends PdfListField {
/**
* Represents a combo box field of the PDF document.
*
* @private
*/
constructor();
/**
* Represents a combo box field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The name of the field.
* @param {Rectangle} bounds The bounds of the field.
* ```typescript
* // 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();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle);
/**
* Represents a combo box (drop-down) field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} [name] The unique name of the field.
* @param {Rectangle} bounds The bounds of the field.
* @param {object} properties Required properties bag.
* @param {{text: string, value: string}[]} properties.items List items to populate (text/value pairs).
* @param {string} [properties.toolTip] Tooltip text shown by the viewer.
* @param {PdfColor} [properties.color] Fore color (text color) of the field (RGB).
* @param {PdfColor} [properties.backColor] Background color.
* @param {PdfColor} [properties.borderColor] Border color.
* @param {PdfInteractiveBorder} [properties.border] Border settings (width, style, dash).
* @param {number|number[]} [properties.selectedIndex] Selected index (single) or indices (multi) if viewer supports it.
* @param {string|string[]} [properties.selectedValue] Selected value (single) or values (multi) matching items.
* @param {PdfFont} [properties.font] Font used for the drop-down text.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Get the first page of the document
* let page: PdfPage = document.getPage(0);
* // Add new combobox field into PDF form
* document.form.add(new PdfComboBoxField(
* page,
* 'Country',
* { x: 50, y: 400, width: 180, height: 22 },
* {
* items: [
* { text: 'United States', value: 'US' },
* { text: 'Canada', value: 'CA' },
* { text: 'Germany', value: 'DE' }
* ],
* toolTip: 'Choose a country',
* color: { r: 0, g: 0, b: 0 },
* backColor: { r: 255, g: 255, b: 255 },
* borderColor: { r: 0, g: 0, b: 0 },
* border: new PdfInteractiveBorder({width: 1, style: PdfBorderStyle.solid}),
* selectedIndex: 0,
* font: document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular)
* }
* ));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle, properties: {
items: {
text: string;
value: string;
}[];
toolTip?: string;
color?: PdfColor;
backColor?: PdfColor;
borderColor?: PdfColor;
border?: PdfInteractiveBorder;
selectedIndex?: number;
font?: PdfFont;
});
/**
* Gets the boolean flag indicates whether the combo box field is auto size.
*
* @private
* @returns {boolean} Returns the boolean value to check auto size.
*/
readonly _isAutoFontSize: boolean;
/**
* Parse an existing combo box field.
*
* @private
* @param {PdfForm} form Form object.
* @param {_PdfDictionary} dictionary Field dictionary.
* @param {_PdfCrossReference} crossReference Cross reference object.
* @param {_PdfReference} reference Field reference.
* @returns {PdfComboBoxField} Combo box field.
*/
static _load(form: PdfForm, dictionary: _PdfDictionary, crossReference: _PdfCrossReference, reference: _PdfReference): PdfComboBoxField;
/**
* Loads display texts for the fields items from the dictionary `Opt` array and
* assigns them to the corresponding widget items `_text` property.
*
* @private
* @returns {void}
*/
_retrieveOptionValue(): void;
/**
* Creates the appearance template for the list/combobox field (or a specific widget item),
* computing effective bounds (respecting page/field rotation), border, background, colors,
* and string formatting, then renders the widget content.
*
* @private
* @param {PdfListFieldItem} [item] The specific widget item to render; when omitted, renders the field level appearance.
* @returns {PdfTemplate} The generated appearance template for the current visual state.
*/
_createAppearance(item?: PdfListFieldItem): PdfTemplate;
/**
* Draws the combobox/list widget: background, border, clipping, and the currently
* selected items text (resolved from `I` and `Opt`), honoring padding and rotation.
*
* @private
* @param {PdfGraphics} graphics The graphics context used for rendering.
* @param {_PaintParameter} [parameter] The paint parameters including bounds, colors, border, rotation, and string format.
* @param {PdfFont} [font] The font to use for rendering the selected items text.
* @param {PdfStringFormat} [stringFormat] The text layout configuration (alignment and line alignment).
* @returns {void}
*/
_drawComboBox(graphics: PdfGraphics, parameter?: _PaintParameter, font?: PdfFont, stringFormat?: PdfStringFormat): void;
/**
* Computes a suitable font size (height) for rendering the selected value within
* the field bounds, based on the specified font family and current option text widths.
* Ensures the text fits the available width/height by scaling within border padding.
*
* @private
* @param {PdfFontFamily} fontFamily The font family to measure and scale.
* @returns {number} The resolved font size in points that fits the controls content.
*/
_getFontHeight(fontFamily: PdfFontFamily): number;
}
/**
* `PdfListBoxField` class represents the list box field objects.
* ```typescript
* // 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 list box field
* let field: PdfListBoxField = new PdfListBoxField(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 list 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();
* ```
*/
export declare class PdfListBoxField extends PdfListField {
/**
* Represents a list box field of the PDF document.
*
* @private
*/
constructor();
/**
* Represents a list box field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The name of the field.
* @param {Rectangle} bounds The bounds of the field.
* ```typescript
* // 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 list box field
* let field: PdfListBoxField = new PdfListBoxField(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 list 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();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle);
/**
* Represents a list box field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} name The unique name of the field.
* @param {Rectangle} bounds The bounds of the field.
* @param {object} properties Required properties bag.
* @param {{text: string, value: string}[]} properties.items List items to populate (text/value pairs).
* @param {string} [properties.toolTip] Tooltip text shown by the viewer.
* @param {PdfColor} [properties.color] Fore color (text color) of the field (RGB).
* @param {PdfColor} [properties.backColor] Background color.
* @param {PdfColor} [properties.borderColor] Border color.
* @param {PdfInteractiveBorder} [properties.border] Border settings (width, style, dash).
* @param {number|number[]} [properties.selectedIndex] Selected index or indices (for multi-select).
* @param {string|string[]} [properties.selectedValue] Selected value(s) matching items[].value.
* @param {boolean} [properties.multiSelect] Allow selecting multiple items (viewer dependent).
* @param {PdfFont} [properties.font] Font used for item text.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Get the first page of the document
* let page: PdfPage = document.getPage(0);
* // Add new listbox field into PDF form
* document.form.add(new PdfListBoxField(
* page,
* 'Languages',
* { x: 50, y: 340, width: 180, height: 60 },
* {
* items: [
* { text: 'English', value: 'en' },
* { text: 'French', value: 'fr' },
* { text: 'German', value: 'de' }
* ],
* toolTip: 'Select language(s)',
* color: { r: 0, g: 0, b: 0 },
* backColor: { r: 255, g: 255, b: 255 },
* borderColor: { r: 0, g: 0, b: 0 },
* border: new PdfInteractiveBorder({width: 1, style: PdfBorderStyle.solid}),
* selectedIndex: [0, 2],
* multiSelect: true,
* font: document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular)
* }
* ));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle, properties: {
items: {
text: string;
value: string;
}[];
toolTip?: string;
color?: PdfColor;
backColor?: PdfColor;
borderColor?: PdfColor;
border?: PdfInteractiveBorder;
selectedIndex?: number | number[];
multiSelect?: boolean;
font?: PdfFont;
});
/**
* Parse an existing list box field of the PDF document.
*
* @private
* @param {number} form maximum length.
* @param {_PdfDictionary} dictionary maximum length.
* @param {_PdfCrossReference} crossReference maximum length.
* @param {_PdfReference} reference maximum length.
* @returns {PdfListBoxField} List box field.
*/
static _load(form: PdfForm, dictionary: _PdfDictionary, crossReference: _PdfCrossReference, reference: _PdfReference): PdfListBoxField;
/**
* Reads the field's `Opt` array, prepares the internal `_listValues` cache, and
* assigns display text to each widget item’s `_text`. Also updates the current
* `_selectedIndex` from the `I` entry when available.
*
* @private
* @returns {void}
*/
_retrieveOptionValue(): void;
/**
* Creates the appearance template for the list box field ,
* computing effective bounds , border, background,
* and text formatting, then renders the widget content.
*
* @private
* @param {PdfListFieldItem} [item] The specific widget item to render; when omitted, renders the field-level appearance.
* @returns {PdfTemplate} The generated appearance template for the current visual state.
*/
_createAppearance(item?: PdfListFieldItem): PdfTemplate;
/**
* Draws the list box control including background, border, clipping, selection highlight,
* and each options text, honoring padding and rotation settings.
*
* @private
* @param {PdfGraphics} graphics The graphics context used for rendering.
* @param {_PaintParameter} [parameter] The paint parameters including bounds, colors, border, rotation, and layout.
* @param {PdfFont} [font] The font to use for rendering list items.
* @param {PdfStringFormat} [stringFormat] The text layout configuration (alignment and line alignment).
* @returns {void}
*/
_drawListBox(graphics: PdfGraphics, parameter?: _PaintParameter, font?: PdfFont, stringFormat?: PdfStringFormat): void;
/**
* Computes an appropriate font size (height) for rendering list items so that text
* fits within the field's width accounting for border padding based on measured
* widths of `_listValues`.
*
* @private
* @param {PdfFontFamily} fontFamily The font family used for measurement and scaling.
* @returns {number} The resolved font size in points (capped to a maximum of 12).
*/
_getFontHeight(fontFamily: PdfFontFamily): number;
}
/**
* `PdfSignatureField` class represents the signature field objects.
* ```typescript
* // 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 signature field
* let field: PdfSignatureField = new PdfSignatureField(page, 'Signature', {x: 10, y: 10, width: 100, height: 50});
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
export declare class PdfSignatureField extends PdfField {
/**
* Primary widget annotation for the signature field.
*
* @private
*/
_widgetAnnot: PdfWidgetAnnotation;
/**
* Appearance object used to render the signature.
*
* @private
*/
_appearance: PdfAppearance;
private _rotateAngle;
/**
* Digital signature associated with this field.
*
* @private
*/
_signature: PdfSignature;
/**
* Indicates whether the field already contains a signature.
*
* @private
*/
_isSigned: boolean;
private _revision;
/**
* Represents a signature field of the PDF document.
*
* @private
*/
constructor();
/**
* Represents a signature field of the PDF document.
*
* @private
* @param {PdfPage} page The page to which the signature field is added.
* @param {string} name The name of the signature field.
* @param {Rectangle} bounds The bounds of the signature field.
* ```typescript
* // 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 signature field
* let field: PdfSignatureField = new PdfSignatureField(page, 'Signature', {x: 10, y: 10, width: 100, height: 50});
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle);
/**
* Represents a signature field of the PDF document.
*
* @param {PdfPage} page The page where the field is drawn.
* @param {string} [name] The unique name of the field.
* @param {Rectangle} bounds The bounds of the field (typically a visible area for signature appearance).
* @param {object} properties Required properties bag.
* @param {string} [properties.toolTip] Tooltip text shown by the viewer.
* @param {PdfColor} [properties.color] Fore color used in the appearance (RGB).
* @param {PdfColor} [properties.backColor] Background color.
* @param {PdfColor} [properties.borderColor] Border color.
* @param {PdfInteractiveBorder} [properties.border] Border settings (width, style, dash).
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Get the first page of the document
* let page: PdfPage = document.getPage(0);
* // Add new signature field into PDF form
* document.form.add(new PdfSignatureField(
* page,
* 'ApprovalSignature',
* { x: 50, y: 260, width: 200, height: 40 },
* {
* toolTip: 'Sign here',
* color: { r: 0, g: 0, b: 0 },
* backColor: { r: 255, g: 255, b: 255 },
* borderColor: { r: 0, g: 0, b: 0 },
* border: new PdfInteractiveBorder({width: 1, style: PdfBorderStyle.solid})
* }
* ));
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(page: PdfPage, name: string, bounds: Rectangle, properties: {
toolTip?: string;
color?: PdfColor;
backColor?: PdfColor;
borderColor?: PdfColor;
border?: PdfInteractiveBorder;
});
/**
* Gets the flag to indicate whether the field is signed or not.
*
* @returns {boolean} Returns true if the field is signed; otherwise, false.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the loaded signature field
* let field: PdfSignatureField = document.form.fieldAt(0) as PdfSignatureField;
* // Get the signed status of the field
* let isSigned: boolean = field.isSigned;
* // Destroy the document
* document.destroy();
* ```
*/
readonly isSigned: boolean;
/**
* Gets the background color of the field.
*
* @returns {PdfColor} R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the form field at index 0
* let field: PdfField = document.form.fieldAt(0);
* // Gets the background color of the field.
* let backColor: PdfColor = field.backColor;
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the background color of the field.
*
* @param {PdfColor} value Array with R, G, B color values in between 0 to 255.
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data, password);
* // Access the signature field at index 0
* let field1: PdfField = document.form.fieldAt(0);
* // Sets the background color of the field.
* field1.backColor = {r: 255, g: 0, b: 0};
* // Access the signature field at index 1
* let field2: PdfField = document.form.fieldAt(1);
* // Sets the background color of the field to transparent.
* field2.backColor = {r: 0, g: 0, b: 0, isTransparent: true};
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
backColor: PdfColor;
/**
* Loads a signature field from the specified dictionary and reference, binding it
* to the owning form and cross-reference, and initializes its kids and caches.
*
* @private
* @param {PdfForm} form The parent form that owns this signature field.
* @param {_PdfDictionary} dictionary The field dictionary from which to load properties.
* @param {_PdfCrossReference} crossReference The cross-reference table for object resolution.
* @param {_PdfReference} reference The indirect reference identifying this field.
* @returns {PdfSignatureField} The initialized signature field instance in a loaded state.
*/
static _load(form: PdfForm, dictionary: _PdfDictionary, crossReference: _PdfCrossReference, reference: _PdfReference): PdfSignatureField;
/**
* Gets the signature associated with the PDF signature field.
*
* ```typescript
* // Load the 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;
* // Gets the signature field
* let field: PdfSignatureField = form.fieldAt(0) as PdfSignatureField;
* // Gets the PDF signature
* let signature: PdfSignature = field.getSignature();
* // Gets the signature options
* let options: PdfSignatureOptions = signature.getSignatureOptions();
* // Gets the cryptographic standard of the signature
* let cryptographicStandard: CryptographicStandard = options.cryptographicStandard;
* // Destroy the document
* document.destroy();
* ```
*
* @returns {PdfSignature} - The signature instance.
*/
getSignature(): PdfSignature;
/**
* Sets the signature for the PDF signature field.
*
* ```typescript
* // Load the 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 signature field
* let field: PdfSignatureField = new PdfSignatureField(page, 'Signature', {x: 10, y: 10, width: 100, height: 50});
* // Create a new signature using PFX data and private key
* const sign: PdfSignature = PdfSignature.create(certData, password, { cryptographicStandard: CryptographicStandard.cms, digestAlgorithm: DigestAlgorithm.sha256 });
* // Sets the signature to the field
* field.setSignature(sign);
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {PdfSignature} signature - The signature to assign to the field.
* @returns {void} Nothing.
*/
setSignature(signature: PdfSignature): void;
/**
* Gets the appearance of the PDF signature field.
*
* ```typescript
* // Load the 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 signature field
* let field: PdfSignatureField = new PdfSignatureField(page, 'Signature', {x: 10, y: 10, width: 100, height: 50});
* // Create a new signature using PFX data and private key
* const sign: PdfSignature = PdfSignature.create(certData, password, { cryptographicStandard: CryptographicStandard.cms, digestAlgorithm: DigestAlgorithm.sha256 });
* // Sets the signature to the field
* field.setSignature(sign);
* // Gets the field Appearance
* let appearance = field.getAppearance();
* // Add the field into PDF form
* form.add(field);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @returns {PdfAppearance} - The appearance of the PDF signature field.
*/
getAppearance(): PdfAppearance;
/**
* Gets the revision index of the PDF signature field.
*
* ```typescript
* // Load an existing PDF document
* let document: PdfDocument = new PdfDocument(data);
* // Access the PDF form
* let form: PdfForm = document.form;
* // Gets the signature field
* let signature: PdfSignatureField = form.fieldAt(0) as PdfSignatureField;
* // Gets the revision number associated with the signature field
* let revision: number = signature.getRevision();
* // Destroy the document
* document.destroy();
* ```
*
* @returns {number} - The revision index of the signature.
*/
getRevision(): number;
/**
* Initializes the signature field on the specified page with the given name and bounds,
* creating its dictionary, reference, default font, and the initial widget item.
*
* @private
* @param {PdfPage} page The page on which the signature field is created.
* @param {string} name The field name to assign to the signature field.
* @param {{x: number, y: number, width: number, height: number}} bounds The field bounds in page coordinates. // eslint-disable-line
* @returns {void}
*/
_initialize(page: PdfPage, name: string, bounds: {
x: number;
y: number;
width: number;
height: number;
}): void;
/**
* Creates and adds the signature field’s primary widget annotation using the provided bounds,
* sets up appearance-related entries (`MK`, `BC`, `BG`, `DA`), and adds it to the Kids array.
*
* @private
* @param {{x: number, y: number, width: number, height: number}} bounds The widget bounds in page coordinates.
* @returns {void}
*/
_createItem(bounds: {
x: number;
y: number;
width: number;
height: number;
}): void;
/**
* Finalizes the signature field after updates by generating or attaching appearances,
* handling signature locking if required, and optionally flattening the field to static content.
*
* @private
* @param {boolean} [isFlatten=false] When `true`, flattens appearances into the page content.
* @returns {void}
*/
_doPostProcess(isFlatten?: boolean): void;
/**
* Builds a visual appearance template for the signature widget, applying border, background,
* colors, and rotation. When flattening, fills background if specified.
*
* @private
* @param {PdfWidgetAnnotation} widget The signature widget for which to create the appearance.
* @param {boolean} isFlatten Indicates whether the appearance is being created for flattening.
* @returns {PdfTemplate} The generated appearance template for the widget.
*/
_createAppearance(widget: PdfWidgetAnnotation, isFlatten: boolean): PdfTemplate;
/**
* Draws the signature appearance onto the specified page at the given bounds, using the
* widget or field appearance stream (`AP`) if present, or a provided template.
*
* @private
* @param {_PdfDictionary} dictionary The widget or field dictionary containing appearance entries.
* @param {PdfPage} page The page on which to draw the signature appearance.
* @param {{x: number, y: number, width: number, height: number}} bounds The drawing bounds on the page.
* @param {PdfTemplate} [signatureTemplate] Optional predefined appearance template to use when `AP` is absent.
* @returns {void}
*/
_flattenSignature(dictionary: _PdfDictionary, page: PdfPage, bounds: {
x: number;
y: number;
width: number;
height: number;
}, signatureTemplate?: PdfTemplate): void;
/**
* Computes transformed template bounds for the current page rotation, applying
* the appropriate translate/rotate transforms to the graphics context.
*
* @private
* @param {{x: number, y: number, width: number, height: number}} bounds The original widget bounds.
* @param {PdfPage} page The page whose rotation and size influence the transformed bounds.
* @param {PdfTemplate} template The template being drawn (used for size/transform).
* @param {PdfGraphics} graphics The graphics context to which transforms are applied.
* @returns {{x: number, y: number, width: number, height: number}} The adjusted bounds after transformation.
*/
_calculateTemplateBounds(bounds: {
x: number;
y: number;
width: number;
height: number;
}, page: PdfPage, template: PdfTemplate, graphics: PdfGraphics): {
x: number;
y: number;
width: number;
height: number;
};
/**
* Determines the effective rotation angle (0/90/180/270) of the graphics context
* based on the provided transformation matrix.
*
* @private
* @param {_PdfTransformationMatrix} matrix The transformation matrix of the graphics context.
* @returns {number} The normalized rotation angle in degrees.
*/
_obtainGraphicsRotation(matrix: _PdfTransformationMatrix): number;
/**
* Retrieves the normal appearance template from the given dictionarys `AP` entry,
* if present, and binds its reference.
*
* @private
* @param {_PdfDictionary} dictionary The widget or field dictionary to read the appearance from.
* @returns {PdfTemplate} The extracted appearance template, or `undefined` if not available.
*/
_getItemTemplate(dictionary: _PdfDictionary): PdfTemplate;
/**
* Checks the field dictionary for a populated `V` entry to determine if the signature
* has been applied and updates the internal signed state.
*
* @private
* @returns {void}
*/
_checkSigned(): void;
private _getSignedRevision;
}
/**
* Represents a parsed default appearance (`DA`) definition, capturing font name,
* font size, and RGB color to be used for text rendering.
*
* @private
*/
export declare class _PdfDefaultAppearance {
fontName: string;
fontSize: number;
color: PdfColor;
constructor(da?: string);
toString(): string;
}