Pdf Component - PdfGoToAction
18 Nov 20263 minutes to read
Represents an action that navigates to a destination in the current PDF document.
// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let firstPage: PdfPage = document.addPage();
let secondPage: PdfPage = document.addPage();
// Create a destination and GoTo action
let destination: PdfDestination = new PdfDestination(secondPage);
let action: PdfGoToAction = new PdfGoToAction(destination);
// Create a button and assign the action
let field: PdfButtonField = new PdfButtonField(
firstPage, 'GoTo', { x: 20, y: 20, width: 120, height: 30 }
);
field.text = 'Go to page';
field.actions.mouseUp = action;
document.form.add(field);
// Save and destroy the document
document.save('output.pdf');
document.destroy();Properties
Get destination PdfDestination
Gets the destination to navigate to.
// 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 GoTo action and destination
let action: PdfGoToAction = field.actions.mouseUp as PdfGoToAction;
let destination: PdfDestination = action.destination;
// Save and destroy the document
document.save('output.pdf');
document.destroy();Set destination void
Sets the destination to navigate to.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
let page: PdfPage = document.getPage(1);
// Get the button field and GoTo action
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
let action: PdfGoToAction = field.actions.mouseUp as PdfGoToAction;
// Set the destination
action.destination = new PdfDestination(page, { x: 0, y: 100 });
// Save and destroy the document
document.save('output.pdf');
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | PdfDestination |
The destination to navigate to. |
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. |