Table of Contents

Class PdfJavaScriptAction

Namespace
Syncfusion.Pdf.Interactive
Assembly
Syncfusion.Pdf.Portable.dll

Represents an java script action in PDF document.

public class PdfJavaScriptAction : PdfAction
Inheritance
PdfJavaScriptAction
Inherited Members

Examples

//Create a new document
 PdfDocument document = new PdfDocument();
 //Add a page.
 PdfPage page = document.Pages.Add();
 //Create JavaScript action
 PdfJavaScriptAction javaScriptAction = new PdfJavaScriptAction("app.alert(\"Hello World!!!\")");
 //Add the JavaScript action
 document.Actions.AfterOpen = javaScriptAction;
 //Save and close the PDF document
 document.Save("Output.pdf");
 document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create JavaScript action
Dim javaScriptAction As New PdfJavaScriptAction("app.alert(""Hello World!!!"")")
'Add the JavaScript action
document.Actions.AfterOpen = javaScriptAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)

Remarks

This PdfJavaScriptAction class is used to perform the java script action in PDF document. Please refer the UG docuemntation link for more details.

Constructors

PdfJavaScriptAction(string)

Initializes a new instance of the PdfJavaScriptAction class with java script code

public PdfJavaScriptAction(string javaScript)

Parameters

javaScript string

The java script code.

Examples

//Create a new document
 PdfDocument document = new PdfDocument();
 //Add a page.
 PdfPage page = document.Pages.Add();
 //Create JavaScript action
 PdfJavaScriptAction javaScriptAction = new PdfJavaScriptAction("app.alert(\"Hello World!!!\")");
 //Add the JavaScript action
 document.Actions.AfterOpen = javaScriptAction;
 //Save and close the PDF document
 document.Save("Output.pdf");
 document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create JavaScript action
Dim javaScriptAction As New PdfJavaScriptAction("app.alert(""Hello World!!!"")")
'Add the JavaScript action
document.Actions.AfterOpen = javaScriptAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)

Properties

JavaScript

Gets or sets the javascript code to be executed when this action is executed.

public string JavaScript { get; set; }

Property Value

string

A string value representing valid javascript code to be executed.

Examples

//Create a new document
 PdfDocument document = new PdfDocument();
 //Add a page.
 PdfPage page = document.Pages.Add();
 //Create JavaScript action
 PdfJavaScriptAction javaScriptAction = new PdfJavaScriptAction("app.alert(\"Hello World!!!\")");
 //Get the javascript code.
 string javascriptcode = javaScriptAction.JavaScript;
 //Add the JavaScript action
 document.Actions.AfterOpen = javaScriptAction;
 //Save and close the PDF document
 document.Save("Output.pdf");
 document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create JavaScript action
Dim javaScriptAction As New PdfJavaScriptAction("app.alert(""Hello World!!!"")")
'Get the javascript code.
Dim javascriptcode As String = javaScriptAction.JavaScript
'Add the JavaScript action
document.Actions.AfterOpen = javaScriptAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)

Methods

Initialize()

Initializes instance.

protected override void Initialize()