This sample shows how to use buttons in your PDF document.

You can add buttons to your PDF document using PdfPage.AddButton(..) method. This method returns an instance of PdfButton class.

You can also associate actions with buttons using properties in PdfButton class whose names start with "On" (e.g. OnMouseDown).

CopyC#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class Buttons
    {
        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.

            PdfDocument pdf = new PdfDocument();
            PdfPage page = pdf.Pages[0];

            PdfButton button = page.AddButton(10, 50, 100, 50);
            button.BackgroundColor = new PdfGrayColor(60);
            button.BorderColor = new PdfRgbColor(128, 0, 128);
            button.Text = "Button";

            string pathToFile = "Buttons.pdf";
            pdf.Save(pathToFile);
            pdf.Dispose();

            Process.Start(pathToFile);
        }
    }
}
CopyVB.NET
Imports System.Diagnostics
Imports System.IO

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class Buttons
        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.


            Dim pdf As New PdfDocument()
            Dim page As PdfPage = pdf.Pages(0)

            Dim button As PdfButton = page.AddButton(10, 50, 100, 50)
            button.BackgroundColor = New PdfGrayColor(60)
            button.BorderColor = New PdfRgbColor(128, 0, 128)
            button.Text = "Button"

            Dim pathToFile As String = "Buttons.pdf"
            pdf.Save(pathToFile)
            pdf.Dispose()

            Process.Start(pathToFile)
        End Sub
    End Class
End Namespace