PDF Mosaic: How to add Go To Action in PDF document


Home       Features       Download       Tutorial       Version History       License       PDF Mosaic Blog       Source Code

 

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);
            document.Pages.Add(page1);
            document.Pages.Add(page2);
 
            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;
            page1.Annotations.Add(button);
 
            document.Save("GoToAction.pdf", true);
        }
    }
}

 


Home       Features       Download       Tutorial       Version History       License       PDF Mosaic Blog       Source Code