This sample shows how to remove widgets from your PDF documents.

Use PdfPage.Widgets and PdfDocument.Widgets properties to access collection of page or document widgets. To remove widgets from any of these two collections you can use PdfWidgetCollection.Clear(), PdfWidgetCollection.Remove() and PdfWidgetCollection.RemoveAt() methods.

C#
using System.Diagnostics;

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

            using (PdfDocument pdf = new PdfDocument("Sample Data/form.pdf"))
            {
                pdf.Pages[0].Widgets.RemoveAt(1);
                pdf.Save("RemoveWidgetFromPage.pdf");
                Process.Start("RemoveWidgetFromPage.pdf");

                pdf.Widgets.Clear();

                pdf.Save("RemoveWidgets.pdf");
            }

            Process.Start("RemoveWidgets.pdf");
        }
    }
}
VB
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

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

            Using pdf As New PdfDocument("Sample Data/form.pdf")
                pdf.Pages(0).Widgets.RemoveAt(1)
                pdf.Save("RemoveWidgetFromPage.pdf")
                Process.Start("RemoveWidgetFromPage.pdf")

                pdf.Widgets.Clear()

                pdf.Save("RemoveWidgets.pdf")
            End Using

            Process.Start("RemoveWidgets.pdf")
        End Sub
    End Class
End Namespace