This sample shows how to use Go-To actions.

A Go-To (or jump) action can be created using PdfDocument.CreateGoToPageAction() method. CreateGoToPageAction method returns an instance of PdfGoToAction class.

Using methods and properties of PdfGoToAction class you can specify a target page to be shown as the result of the action. You can also specify the upper-left corner of the target page to be positioned at the upper-left corner of the window using PdfGoToAction.Offset property.

A go-to action (and a number of other action types) can be used for widget event handlers (e.g. for PdfButton.OnMouseDown property).

C#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class GoToAction
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            using (PdfDocument pdf = new PdfDocument())
            {
                PdfPage secondPage = pdf.AddPage();
                secondPage.Canvas.DrawString(10, 300, "Go-to action target");

                PdfGoToAction action = pdf.CreateGoToPageAction(1, 300);
                PdfActionArea annotation = pdf.Pages[0].AddActionArea(10, 50, 100, 30, action);
                annotation.BorderColor = new PdfRgbColor(255, 0, 0);
                annotation.BorderDashPattern = new PdfDashPattern(new float[] { 3, 2 });

                pdf.Save("GoToAction.pdf");
            }

            Process.Start("GoToAction.pdf");
        }
    }
}
VB
Imports System.Diagnostics
Imports System.IO

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class GoToAction
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Using pdf As New PdfDocument()

                Dim secondPage As PdfPage = pdf.AddPage()
                secondPage.Canvas.DrawString(10, 300, "Go-to action target")

                Dim action As PdfGoToAction = pdf.CreateGoToPageAction(1, 300)
                Dim annotation As PdfActionArea = pdf.Pages(0).AddActionArea(10, 50, 100, 30, action)
                annotation.BorderColor = New PdfRgbColor(255, 0, 0)
                annotation.BorderDashPattern = New PdfDashPattern(New Single() {3, 2})

                pdf.Save("GoToAction.pdf")
            End Using

            Process.Start("GoToAction.pdf")
        End Sub
    End Class
End Namespace