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

You can add checkboxes to your PDF document using PdfPage.AddCheckBox(..) method. This method returns an instance of PdfCheckBox class.

C#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    static class Checkboxes
    {
        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 = "Checkboxes.pdf";

            using (PdfDocument pdf = new PdfDocument())
            {
                PdfPage page = pdf.Pages[0];
                page.AddCheckBox(10, 50, 120, 15, "Check box");

                PdfCheckBox readonlyCheckBox = page.AddCheckBox(10, 100, 120, 15, "Read-only check box");
                readonlyCheckBox.ReadOnly = true;
                readonlyCheckBox.Checked = true;

                PdfCheckBox checkBoxWithBorder = page.AddCheckBox(10, 150, 140, 15, "Check box with colored border");
                checkBoxWithBorder.BorderColor = new PdfCmykColor(40, 90, 70, 3);

                pdf.Save(pathToFile);
            }

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

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    NotInheritable Class Checkboxes
        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 = "Checkboxes.pdf"

            Using pdf As New PdfDocument()

                Dim page As PdfPage = pdf.Pages(0)
                page.AddCheckBox(10, 50, 120, 15, "Check box")

                Dim readonlyCheckBox As PdfCheckBox = page.AddCheckBox(10, 100, 120, 15, "Read-only check box")
                readonlyCheckBox.[ReadOnly] = True
                readonlyCheckBox.Checked = True

                Dim checkBoxWithBorder As PdfCheckBox = page.AddCheckBox(10, 150, 140, 15, "Check box with colored border")
                checkBoxWithBorder.BorderColor = New PdfCmykColor(40, 90, 70, 3)

                pdf.Save(pathToFile)
            End Using

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