Skip to content

happypdf / PDFJavaScriptAction

Class: PDFJavaScriptAction

Defined in: src/api/PDFJavaScriptAction.ts:17

Represents a JavaScript action extracted from a PDF. JavaScript actions can be attached to documents, pages, fields, and annotations.

Properties

dict

ts
readonly dict: PDFDict;

Defined in: src/api/PDFJavaScriptAction.ts:19

The underlying dictionary for this JavaScript action.


doc

ts
readonly doc: PDFDocument;

Defined in: src/api/PDFJavaScriptAction.ts:22

The document to which this action belongs.


ref?

ts
readonly optional ref?: PDFRef;

Defined in: src/api/PDFJavaScriptAction.ts:25

The reference to this action (if any).

Methods

getScript()

ts
getScript(): string | undefined;

Defined in: src/api/PDFJavaScriptAction.ts:56

Get the JavaScript code from this action.

Returns

string | undefined

The JavaScript code as a string


of()

ts
static of(
   dict, 
   doc, 
   ref?): PDFJavaScriptAction | undefined;

Defined in: src/api/PDFJavaScriptAction.ts:40

Create a PDFJavaScriptAction from a dictionary.

Parameters

ParameterTypeDescription
dictPDFDictThe action dictionary
docPDFDocumentThe document to which this action belongs
ref?PDFRefThe reference to this action (if any)

Returns

PDFJavaScriptAction | undefined

A PDFJavaScriptAction instance or undefined if not a JavaScript action


setScript()

ts
setScript(script): void;

Defined in: src/api/PDFJavaScriptAction.ts:78

Set the JavaScript code for this action.

Parameters

ParameterTypeDescription
scriptstringThe JavaScript code to set

Returns

void

MIT Licensed. A fork of pdf-lib.