How To Add Go To Action In PDF Document Using PDF Mosiac .NET Library

This sample shows how to use Go-To actions.
Using methods and properties of PDFGoToAction class you can specify a target page to be shown as the result of the action.


using PDFMosaic;
using System;

namespace GoToAction
    class GoToAction
        static void Main()
            PDFDocument document = new PDFDocument();

            PDFPage page1 = new PDFPage(PDFPaperFormat.A4);
            PDFPage page2 = new PDFPage(PDFPaperFormat.A4);

            PDFFont fnt = new PDFFont(PDFStandardFont.Helvetica, 12);
            PDFBrush br = new PDFSolidBrush();
            page2.Canvas.DrawString("Action target", fnt, br, 100, 200);

            PDFGoToAction action = new PDFGoToAction(new PDFDestination(page2, 200));
            PDFPushButton button = new PDFPushButton(20, 40, 80, 20, "btn1");
            button.Caption = "Click me";
            button.OnActivated = action;
            document.Save("GoToAction.pdf", true);