Pdf - PdfLaunchAction

18 Nov 20266 minutes to read

Represents an action that launches an external file or application.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create a file specification
let fileSpecification: PdfFileSpecification = new PdfFileSpecification('input.pdf');
// Create a launch action
let action: PdfLaunchAction = new PdfLaunchAction(fileSpecification, true);
// Create a button and assign the action
let field: PdfButtonField = new PdfButtonField(
    page, 'Launch', { x: 20, y: 20, width: 120, height: 30 }
);
field.text = 'Open file';
field.actions.mouseUp = action;
document.form.add(field);
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Properties

Get fileSpecification PdfFileSpecification

Gets the file specification associated with the action.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the button field
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the launch action
let action: PdfLaunchAction = field.actions.mouseUp as PdfLaunchAction;
// 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 associated with the action.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the button field
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the launch action
let action: PdfLaunchAction = field.actions.mouseUp as PdfLaunchAction;
// Create and set a file specification
let fileSpecification: PdfFileSpecification = new PdfFileSpecification('updated.pdf');
action.fileSpecification = fileSpecification;
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value PdfFileSpecification The file specification to associate with the action.

Get isNewWindow boolean

Gets whether the external file or application opens in a new window.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the button field
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the launch action
let action: PdfLaunchAction = field.actions.mouseUp as PdfLaunchAction;
// Get the new-window setting
let isNewWindow: boolean = action.isNewWindow;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set isNewWindow void

Sets whether the external file or application opens in a new window.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the button field
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the launch action
let action: PdfLaunchAction = field.actions.mouseUp as PdfLaunchAction;
// Open the target in a new window
action.isNewWindow = true;
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value boolean true to open the target in a new window; 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.

Get windowsParameter PdfWindowsLaunchParameters

Gets the Windows-specific launch parameters.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the button field
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the launch action
let action: PdfLaunchAction = field.actions.mouseUp as PdfLaunchAction;
// Get the Windows-specific launch parameters
let windowsParameter: PdfWindowsLaunchParameters = action.windowsParameter;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set windowsParameter void

Sets the Windows-specific launch parameters.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the button field
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the launch action
let action: PdfLaunchAction = field.actions.mouseUp as PdfLaunchAction;
// Create and set Windows-specific launch parameters
let windowsParameter: PdfWindowsLaunchParameters = new PdfWindowsLaunchParameters();
windowsParameter.fileName = 'updated.pdf';
windowsParameter.operation = 'open';
action.windowsParameter = windowsParameter;
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value PdfWindowsLaunchParameters The Windows-specific launch parameters.