Class PdfJavaScriptAction
Represents an java script action in PDF document.
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfJavaScriptAction : PdfAction, IPdfWrapper
Remarks
This PdfJavaScriptAction class is used to perform the java script action in PDF document. Please refer the UG docuemntation link https://help.syncfusion.com/file-formats/pdf/working-with-action#javascript-action for more details.
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)
Constructors
PdfJavaScriptAction(String)
Initializes a new instance of the PdfJavaScriptAction class with java script code
Declaration
public PdfJavaScriptAction(string javaScript)
Parameters
Type | Name | Description |
---|---|---|
System.String | javaScript | 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.
Declaration
public string JavaScript { get; set; }
Property Value
Type | Description |
---|---|
System.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.
Declaration
protected override void Initialize()