Pdf - PdfDocumentActions
18 Nov 202611 minutes to read
Represents actions associated with document-level events in a PDF document.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add two pages to the document
document.addPage();
document.addPage();
// Create a named action that navigates to the last page
const action: PdfNamedAction =
new PdfNamedAction(
PdfActionDestination.LastPage
);
// Assign the action to the document open event
document.actions.afterOpen = action;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();Properties
Get afterOpen PdfAction
Gets the action executed when the document is opened.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add two pages to the document
document.addPage();
document.addPage();
// Create a named action that navigates to the last page
const action: PdfNamedAction =
new PdfNamedAction(
PdfActionDestination.LastPage
);
// Assign the action to the document open event
document.actions.afterOpen = action;
// Get the action assigned to the document open event
const afterOpenAction: PdfAction =
document.actions.afterOpen;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();Set afterOpen void
Sets the action executed when the document is opened.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add two pages to the document
document.addPage();
document.addPage();
// Create a named action that navigates to the last page
const action: PdfNamedAction =
new PdfNamedAction(
PdfActionDestination.LastPage
);
// Assign the action to the document open event
document.actions.afterOpen = action;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | PdfAction |
The action to execute when the document is opened. |
Get afterPrint PdfJavaScriptAction
Gets the JavaScript action executed after the document is printed.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document has been printed');'
);
// Assign the action to the document after-print event
document.actions.afterPrint = action;
// Get the action assigned to the after-print event
const afterPrintAction: PdfJavaScriptAction =
document.actions.afterPrint;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();Set afterPrint void
Sets the JavaScript action executed after the document is printed.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document has been printed');'
);
// Assign the action to the document after-print event
document.actions.afterPrint = action;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | PdfJavaScriptAction |
The JavaScript action to execute after the document is printed. |
Get afterSave PdfJavaScriptAction
Gets the JavaScript action executed after the document is saved.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document has been saved');'
);
// Assign the action to the document after-save event
document.actions.afterSave = action;
// Get the action assigned to the after-save event
const afterSaveAction: PdfJavaScriptAction =
document.actions.afterSave;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();Set afterSave void
Sets the JavaScript action executed after the document is saved.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document has been saved');'
);
// Assign the action to the document after-save event
document.actions.afterSave = action;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | PdfJavaScriptAction |
The JavaScript action to execute after the document is saved. |
Get beforeClose PdfJavaScriptAction
Gets the JavaScript action executed before the document is closed.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document is closing');'
);
// Assign the action to the document before-close event
document.actions.beforeClose = action;
// Get the action assigned to the before-close event
const beforeCloseAction: PdfJavaScriptAction = document.actions.beforeClose;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();Set beforeClose void
Sets the JavaScript action executed before the document is closed.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document is closing');'
);
// Assign the action to the document before-close event
document.actions.beforeClose = action;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | PdfJavaScriptAction |
The JavaScript action to execute before the document is closed. |
Get beforePrint PdfJavaScriptAction
Gets the JavaScript action executed before the document is printed.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document will be printed');'
);
// Assign the action to the document before-print event
document.actions.beforePrint = action;
// Get the action assigned to the before-print event
const beforePrintAction: PdfJavaScriptAction =
document.actions.beforePrint;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();Set beforePrint void
Sets the JavaScript action executed before the document is printed.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document will be printed');'
);
// Assign the action to the document before-print event
document.actions.beforePrint = action;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | PdfJavaScriptAction |
The JavaScript action to execute before the document is printed. |
Get beforeSave PdfJavaScriptAction
Gets the JavaScript action executed before the document is saved.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document will be saved');'
);
// Assign the action to the document before-save event
document.actions.beforeSave = action;
// Get the action assigned to the before-save event
const beforeSaveAction: PdfJavaScriptAction =
document.actions.beforeSave;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();Set beforeSave void
Sets the JavaScript action executed before the document is saved.
// Create a new PDF document
const document: PdfDocument = new PdfDocument();
// Add a page to the document
document.addPage();
// Create a JavaScript action
const action: PdfJavaScriptAction =
new PdfJavaScriptAction(
'app.alert('The document will be saved');'
);
// Assign the action to the document before-save event
document.actions.beforeSave = action;
// Save the PDF document
document.save('output.pdf');
// Destroy the PDF document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | PdfJavaScriptAction |
The JavaScript action to execute before the document is saved. |