This sample shows how to use Hide actions.

Using hide action (see PdfHideAction class) you can make some controls hidden or shown. Use PdfDocument.CreateHideAction to create an instance of PdfHideAction class. Then use PdfHideAction.AddControl method to add controls that should be hidden or shown when the hide action is activated.

C#
using System.Diagnostics;

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

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

                PdfButton hideeButton = page.AddButton(45, 85, 70, 25);
                hideeButton.Text = "Button";

                PdfTextBox hideeTextBox = page.AddTextBox(45, 120, 70, 25);
                hideeTextBox.Text = "TextBox";

                PdfHideAction hideAction = pdf.CreateHideAction(true);
                hideAction.AddControl(hideeButton);
                hideAction.AddControl(hideeTextBox);

                PdfHideAction showAction = pdf.CreateHideAction(false);
                showAction.AddControl(hideeButton);
                showAction.AddControl(hideeTextBox);

                PdfButton showButton = page.AddButton("showBtn", 10, 50, 70, 25);
                showButton.Text = "Show controls";
                showButton.OnMouseUp = showAction;

                PdfButton hideButton = page.AddButton("hideBtn", 90, 50, 70, 25);
                hideButton.Text = "Hide controls";
                hideButton.OnMouseUp = hideAction;

                pdf.Save(pathToFile);
            }

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

Imports BitMiracle.Docotic.Pdf

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

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

                Dim hideeButton As PdfButton = page.AddButton(45, 85, 70, 25)
                hideeButton.Text = "Button"

                Dim hideeTextBox As PdfTextBox = page.AddTextBox(45, 120, 70, 25)
                hideeTextBox.Text = "TextBox"

                Dim hideAction As PdfHideAction = pdf.CreateHideAction(True)
                hideAction.AddControl(hideeButton)
                hideAction.AddControl(hideeTextBox)

                Dim showAction As PdfHideAction = pdf.CreateHideAction(False)
                showAction.AddControl(hideeButton)
                showAction.AddControl(hideeTextBox)

                Dim showButton As PdfButton = page.AddButton("showBtn", 10, 50, 70, 25)
                showButton.Text = "Show controls"
                showButton.OnMouseUp = showAction

                Dim hideButton As PdfButton = page.AddButton("hideBtn", 90, 50, 70, 25)
                hideButton.Text = "Hide controls"
                hideButton.OnMouseUp = hideAction

                pdf.Save(pathToFile)
            End Using

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