This sample shows how to fill forms in existing PDF documents.

When you open a PDF document with a form, you can access and modify document widgets (annotations and controls).

C#
using System.Diagnostics;

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

            using (PdfDocument pdf = new PdfDocument("Sample data/form.pdf"))
            {
                foreach (PdfControl control in pdf.Controls)
                {
                    switch (control.Name)
                    {
                        case "login":
                            ((PdfTextBox)control).Text = "Some Name";
                            break;

                        case "passwd":
                        case "passwd2":
                            PdfTextBox password = (PdfTextBox)control;
                            password.Text = "Password";
                            password.PasswordField = true;
                            break;

                        case "email":
                            ((PdfTextBox)control).Text = "email@gmail.com";
                            break;

                        case "user_viewemail":
                            ((PdfCheckBox)control).Checked = false;
                            break;

                        case "user_sorttopics":
                            // Check the radio button "Show new topics first"
                            PdfRadioButton sortTopics = (PdfRadioButton)control;
                            if (sortTopics.ExportValue == "user_not_sorttopics")
                                sortTopics.Checked = true;

                            break;

                        case "BtnRegister":
                            ((PdfButton)control).ReadOnly = true;
                            break;
                    }
                }

                pdf.Save(pathToFile);
            }

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

Imports BitMiracle.Docotic.Pdf

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

            Using pdf As New PdfDocument("Sample data/form.pdf")
                For Each control As PdfControl In pdf.Controls
                    Select Case control.Name
                        Case "login"
                            DirectCast(control, PdfTextBox).Text = "Some Name"
                            Exit Select

                        Case "passwd", "passwd2"
                            Dim password As PdfTextBox = DirectCast(control, PdfTextBox)
                            password.Text = "Password"
                            password.PasswordField = True
                            Exit Select

                        Case "email"
                            DirectCast(control, PdfTextBox).Text = "email@gmail.com"
                            Exit Select

                        Case "user_viewemail"
                            DirectCast(control, PdfCheckBox).Checked = False
                            Exit Select

                        Case "user_sorttopics"
                            ' Check the radio button "Show new topics first"
                            Dim sortTopics As PdfRadioButton = DirectCast(control, PdfRadioButton)
                            If sortTopics.ExportValue = "user_not_sorttopics" Then
                                sortTopics.Checked = True
                            End If

                            Exit Select

                        Case "BtnRegister"
                            DirectCast(control, PdfButton).[ReadOnly] = True
                            Exit Select
                    End Select
                Next

                pdf.Save(pathToFile)
            End Using

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