Pdf - PdfImportDataAction

18 Nov 20263 minutes to read

Represents an action that imports form data from an FDF or XFDF file.

// 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 an import-data action
let fileSpecification: PdfFileSpecification = new PdfFileSpecification('data.fdf');
let action: PdfImportDataAction = new PdfImportDataAction(fileSpecification);
// Create a button and assign the action
let button: PdfButtonField = new PdfButtonField(
    page, 'ImportData', { x: 20, y: 70, width: 120, height: 30 }
);
button.text = 'Import data';
button.actions.mouseUp = action;
document.form.add(button);
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Properties

Get fileSpecification PdfFileSpecification

Gets the file specification containing the form data.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the import-data button
let button: PdfButtonField = document.form.fieldAt(1) as PdfButtonField;
// Get the import-data action
let action: PdfImportDataAction = button.actions.mouseUp as PdfImportDataAction;
// Get the file specification
let fileSpecification: PdfFileSpecification = action.fileSpecification;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set fileSpecification void

Sets the file specification containing the form data.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the import-data button
let button: PdfButtonField = document.form.fieldAt(1) as PdfButtonField;
// Get the import-data action
let action: PdfImportDataAction = button.actions.mouseUp as PdfImportDataAction;
// Create and set the file specification
let fileSpecification: PdfFileSpecification = new PdfFileSpecification('updated.fdf');
action.fileSpecification = fileSpecification;
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value PdfFileSpecification The file specification containing the form data.

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.