Public Class pdf_form_filling
    Inherits System.Web.UI.Page

    Protected Sub BtnCreatePdf_Click(sender As Object, e As EventArgs)
        ' the initial file
        Dim file As String = Server.MapPath("~/files/w-9.pdf")

        ' load the pdf form manager
        Dim form As New PdfFormManager()
        form.Load(file)

        ' fill some fields
        Dim name As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_1"), PdfFormFieldTextBox)
        name.Text = "This is my name"

        Dim businessName As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_2"), PdfFormFieldTextBox)
        businessName.Text = "This is my business name"

        Dim clasifIndividual As PdfFormFieldCheckBox = _
            TryCast(form.Fields("c1_1"), PdfFormFieldCheckBox)
        clasifIndividual.Checked = True

        Dim address As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_7"), PdfFormFieldTextBox)
        address.Text = "This is my address"

        Dim city As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_8"), PdfFormFieldTextBox)
        city.Text = "This is my city"

        Dim employer1 As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_14"), PdfFormFieldTextBox)
        employer1.Text = "XX"

        Dim employer2 As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_15"), PdfFormFieldTextBox)
        employer2.Text = "1234567"

        Dim ssn1 As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_11"), PdfFormFieldTextBox)
        ssn1.Text = "123"

        Dim ssn2 As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_12"), PdfFormFieldTextBox)
        ssn2.Text = "45"

        Dim ssn3 As PdfFormFieldTextBox = _
            TryCast(form.Fields("f1_13"), PdfFormFieldTextBox)
        ssn3.Text = "6789"

        ' save pdf document
        form.Save(Response, False, "Sample.pdf")

        ' close pdf document
        form.Close()
    End Sub

End Class