'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.AnnotationsImportsGrapeCity.Documents.Pdf.Actions '' Shows how to associate a PDF action with a JavaScript script.'' In this example the script is associated with a link on a page.'' Note that JavaScript may not work in some PDF viewers (e.g. built-in browser viewers).'' See JavaScript for Acrobat for details.PublicClassJavaScriptAction Constjs ="var cChoice = app.popUpMenu(""Introduction"", "" - "", ""Chapter 1""," + vbCrLf +"[ ""Chapter 2"", ""Chapter 2 Start"", ""Chapter 2 Middle""," + vbCrLf +"[""Chapter 2 End"", ""The End""]]);" + vbCrLf +"app.alert(""You chose the '"" + cChoice + ""' menu item"");" FunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Dim g = doc.NewPage().GraphicsDim jsAction = NewActionJavaScript(js)Dim tf = NewTextFormat() With {.Font = StandardFonts.Times, .FontSize = 14}'' Draw the link string in a rectangle:Dim text = "Click this to show the popup menu."Dim rect = NewRectangleF(NewPointF(72, 72), g.MeasureString(text, tf)) g.FillRectangle(rect, Color.LightGoldenrodYellow) g.DrawString(text, tf, rect)Dim result = NewLinkAnnotation(rect, jsAction) doc.Pages.Last.Annotations.Add(result)'' Add warning about this possibly not working in a browser:Util.AddNote("Note that JavaScript may not work in some PDF viewers such as built-in browser viewers.", doc.Pages.Last, NewRectangleF(rect.X, rect.Bottom + 36, 400, 400))'''' Done: doc.Save(stream)Return doc.Pages.CountEndFunctionEndClass