WinForms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfJavaScriptAction

    Show / Hide Table of Contents

    Class PdfJavaScriptAction

    Represents an java script action in PDF document.

    Inheritance
    System.Object
    PdfAction
    PdfJavaScriptAction
    Inherited Members
    PdfAction.Next
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    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 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()
    Overrides
    PdfAction.Initialize()
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved