Skip to content

happypdf / PDFJavaScript

Class: PDFJavaScript ​

Defined in: src/api/PDFJavaScript.ts:10

Represents JavaScript that has been embedded in a [[PDFDocument]].

Implements ​

Properties ​

doc ​

ts
readonly doc: PDFDocument;

Defined in: src/api/PDFJavaScript.ts:29

The document to which this embedded script belongs.


ref ​

ts
readonly ref: PDFRef;

Defined in: src/api/PDFJavaScript.ts:26

The unique reference assigned to this embedded script within the document.

Methods ​

embed() ​

ts
embed(): Promise<void>;

Defined in: src/api/PDFJavaScript.ts:53

> NOTE: You probably don't need to call this method directly. The > [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will > automatically ensure all JavaScripts get embedded.

Embed this JavaScript in its document.

Returns ​

Promise&lt;void&gt;

Resolves when the embedding is complete.

Implementation of ​

Embeddable.embed


of() ​

ts
static of(
   ref, 
   doc, 
   embedder): PDFJavaScript;

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

> NOTE: You probably don't want to call this method directly. Instead, > consider using the [[PDFDocument.addJavaScript]] method, which will create instances of [[PDFJavaScript]] for you.

Create an instance of [[PDFJavaScript]] from an existing ref and script

Parameters ​

ParameterTypeDescription
refPDFRefThe unique reference for this script.
docPDFDocumentThe document to which the script will belong.
embedderJavaScriptEmbedderThe embedder that will be used to embed the script.

Returns ​

PDFJavaScript

MIT Licensed. A fork of pdf-lib.