Pdf - PdfResetFormAction

18 Nov 20266 minutes to read

Represents an action that resets form fields to their default values.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create a text box field
let textField: PdfTextBoxField = new PdfTextBoxField(
    page, 'Name', { x: 20, y: 20, width: 150, height: 30 }
);
document.form.add(textField);
// Create a reset-form action
let action: PdfResetFormAction = new PdfResetFormAction();
action.fields = [textField];
action.include = true;
// Create a button and assign the action
let button: PdfButtonField = new PdfButtonField(
    page, 'ResetForm', { x: 20, y: 70, width: 120, height: 30 }
);
button.text = 'Reset form';
button.actions.mouseUp = action;
document.form.add(button);
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Properties

Get fields PdfField[]

Gets the form fields associated with the action.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the reset button field
let button: PdfButtonField = document.form.fieldAt(1) as PdfButtonField;
// Get the reset-form action
let action: PdfResetFormAction = button.actions.mouseUp as PdfResetFormAction;
// Get the fields associated with the action
let fields: PdfField[] = action.fields;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set fields void

Sets the form fields associated with the action.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create form fields
let nameField: PdfTextBoxField = new PdfTextBoxField(
    page, 'Name', { x: 20, y: 20, width: 150, height: 30 }
);
let cityField: PdfTextBoxField = new PdfTextBoxField(
    page, 'City', { x: 20, y: 60, width: 150, height: 30 }
);
document.form.add(nameField);
document.form.add(cityField);
// Create a reset-form action and set the target fields
let action: PdfResetFormAction = new PdfResetFormAction();
action.fields = [nameField, cityField];
action.include = true;
// Create a button and assign the action
let button: PdfButtonField = new PdfButtonField(
    page, 'ResetForm', { x: 20, y: 110, width: 120, height: 30 }
);
button.actions.mouseUp = action;
document.form.add(button);
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value PdfField[] The form fields to associate with the action.

Get include boolean

Gets whether the specified form fields are included when the action is executed.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the reset button field
let button: PdfButtonField = document.form.fieldAt(1) as PdfButtonField;
// Get the reset-form action
let action: PdfResetFormAction = button.actions.mouseUp as PdfResetFormAction;
// Get whether the specified fields are included
let include: boolean = action.include;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set include void

Sets whether the specified form fields are included when the action is executed.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create a text box field
let textField: PdfTextBoxField = new PdfTextBoxField(
    page, 'Name', { x: 20, y: 20, width: 150, height: 30 }
);
document.form.add(textField);
// Create and configure a reset-form action
let action: PdfResetFormAction = new PdfResetFormAction();
action.fields = [textField];
action.include = true;
// Create a button and assign the action
let button: PdfButtonField = new PdfButtonField(
    page, 'ResetForm', { x: 20, y: 70, width: 120, height: 30 }
);
button.actions.mouseUp = action;
document.form.add(button);
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value boolean true to include the specified fields; otherwise, false.

Get next PdfAction

Get the next action to be performed after the action represented by this instance.

Set next void

Set the next action to be performed after the action represented by this instance.

Parameter Type Description
value PdfAction The next action to be executed.