ByteScout PDF SDK - VB.NET - Actions - JavaScript - ByteScout

ByteScout PDF SDK – VB.NET – Actions – JavaScript

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VB.NET – Actions – JavaScript

ByteScout PDF SDK – VB.NET – Actions – JavaScript

Program.vb

Imports Bytescout.PDF

''' <summary>
''' This example demonstrates how to add JavaScript actions to document events.
''' </summary>
Class Program

    Shared Sub Main()

        ' Create new document
        Dim pdfDocument = New Document()
        pdfDocument.RegistrationName = "demo"
		pdfDocument.RegistrationKey = "demo"
		' Add page
        pdfDocument.Pages.Add(New Page(PaperFormat.A4))

        ' Add action to document open event
        Dim onOpenDocument = New JavaScriptAction("app.alert(""OnOpenDocument"",3)")
        pdfDocument.OnOpenDocument = onOpenDocument

        ' Add action to document close event
        Dim onBeforeClosing = New JavaScriptAction("app.alert(""OnBeforeClosing"",3)")
        pdfDocument.OnBeforeClosing = onBeforeClosing

        ' Save document to file
        pdfDocument.Save("result.pdf")

        ' Cleanup 
		pdfDocument.Dispose()

        ' Open document in default PDF viewer app
        Process.Start("result.pdf")

    End Sub

End Class


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next