This sample shows how to create buttons with images in PDF documents.

You can add an image to a button using PdfButton.Image property. Use PdfButton.Layout property to specify how text and image on the button surfaces should be placed relative to each other. You can also define how the image on the button should be scaled by using the PdfButton.ImageScaleMode property.

C#
using System.Diagnostics;

using BitMiracle.Docotic.Pdf;

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

            string pathToFile = "ButtonImage.pdf";

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

                PdfButton button = page.AddButton(10, 50, 100, 100);
                button.Image = pdf.AddImage(@"Sample Data\\pink.png");
                button.Layout = PdfButtonLayout.ImageOnly;

                pdf.Save(pathToFile);
            }

            Process.Start(pathToFile);
        }
    }
}
VB
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class ButtonImage
        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 pathToFile As String = "ButtonImage.pdf"

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

                Dim button As PdfButton = page.AddButton(10, 50, 100, 100)
                button.Image = pdf.AddImage("Sample Data\\pink.png")
                button.Layout = PdfButtonLayout.ImageOnly

                pdf.Save(pathToFile)
            End Using

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