Pdf - PdfNamedAction

18 Nov 20262 minutes to read

Represents an action that performs a predefined navigation operation in a PDF viewer.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
document.addPage();
// Create a named navigation action
let action: PdfNamedAction = new PdfNamedAction(PdfActionDestination.LastPage);
// Create a button and assign the action
let field: PdfButtonField = new PdfButtonField(
    page, 'NamedAction', { x: 20, y: 20, width: 120, height: 30 }
);
field.text = 'Last page';
field.actions.mouseUp = action;
document.form.add(field);
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Properties

Get destination PdfActionDestination

Gets the predefined navigation destination.

// 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 named action
let action: PdfNamedAction = field.actions.mouseUp as PdfNamedAction;
// Get the predefined navigation destination
let destination: PdfActionDestination = action.destination;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set destination void

Sets the predefined navigation destination.

// 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 named action
let action: PdfNamedAction = field.actions.mouseUp as PdfNamedAction;
// Set the predefined navigation destination
action.destination = PdfActionDestination.FirstPage;
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value PdfActionDestination The predefined navigation destination.

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.