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

This sample shows how to use Launch actions.
A Launch action launches an application or opens a document.

Launch Action

 

using PDFMosaic;
using System;
using System.IO;

namespace LaunchAction
{
    class LaunchAction
    {
        static void Main()
        {
            PDFDocument document = new PDFDocument();
            PDFPage page = new PDFPage(PDFPaperFormat.A4);

            PDFPushButton button = new PDFPushButton(20, 40, 60, 15, "btn1");
            button.Caption = "Launch";
            button.Font.Size = 8;
            page.Annotations.Add(button);

            PDFLaunchAction launchAction = new PDFLaunchAction(Path.GetFullPath("..\\..\\two_pilots.bmp"));
            button.OnActivated = launchAction;

            document.Pages.Add(page);
            document.Save("LaunchAction.pdf", true);
        }
    }
}