Example 01 - Simple: Submit HTML, and populate an Adobe Acrobat PDF form

Imports FDFApp
Partial Public Class example_01
    Inherits System.Web.UI.Page
    Private Debug_Me As Boolean = False
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Me.SubmitButton.Text = "Submit"
            Me.SubmitButton.Enabled = True
            Me.SubmitButton.CssClass = "button button-250 bgRed white"
            Me.ResetButton.CssClass = "button button-250 bgRed white"
            Me.ResetButton.Text = "Reset"
            If Not IsPostBack Then
                Me.FULLNAME.Text = Get_Cookie("Example_FULLNAME") & ""
                Me.EMAIL.Text = Get_Cookie("Example_EMAIL") & ""
                'Me.COMBOBOX.SelectedValue = Get_Cookie("Example_COMBOBOX") & ""
                'Me.CHECKBOX.Checked = Get_Cookie("Example_CHECKBOX") & ""
                'Me.LISTBOX.SelectedValue = CStr(Get_Cookie("Example_LISTBOX") & "")

                Me.SubmitButton.Enabled = True
                Me.SubmitButton.CssClass = "button button-250 bgRed white"
                FULLNAME.Focus()
            End If
            Update_Message("Complete this form, and then press submit.")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub Update_Message(ByVal strMsg As String)
        Me.lblMessage_Top.Text = "Status: " & strMsg
        Me.lblMessage_Bottom.Text = "Status: " & strMsg
    End Sub

    Private Sub ResetButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ResetButton.Click
        Me.SubmitButton.Enabled = True
        Me.SubmitButton.CssClass = "button button-250 bgRed white"
    End Sub

    Private Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
        Page.Validate()
        If (Page.IsValid) Then
            Example()
            Me.SubmitButton.Enabled = True
            Me.SubmitButton.CssClass = "button button-250 bgRed white"
        Else
            Update_Message("Message - Sent Failed!")
        End If
        'End If
    End Sub
    Public Sub Example()
        ' DECLARE FDFApp & FDFDoc Classes
        Dim cFDFApp As New FDFApp.FDFApp_Class
        Dim cFDFDoc As New FDFApp.FDFDoc_Class
        ' INITIALIZE FDFDOC Class
        cFDFDoc = cFDFApp.FDFCreate
        ' SET FILE
        cFDFDoc.FDFSetFile(Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1) & "example.pdf")
        ' SET FIELD VALUES
        cFDFDoc.FDFSetValue("FULLNAME", StripCodeFromString(Me.FULLNAME.Text & ""))
        cFDFDoc.FDFSetValue("EMAIL", StripCodeFromString(Me.EMAIL.Text & ""))
        cFDFDoc.FDFSetValue("COMBOBOX", StripCodeFromString(Me.COMBOBOX.SelectedValue.ToString() & ""))
        cFDFDoc.FDFSetValue("CHECKBOX", Me.CHECKBOX.Checked.ToString())
        cFDFDoc.FDFSetValue("LISTBOX", StripCodeFromString(Me.LISTBOX.SelectedValue.ToString() & ""))
        cFDFDoc.FDFSetValue("RADIOBUTTON", Me.frmRadiobutton0.Checked.ToString())

        Store_Cookie("Example_FULLNAME", StripCodeFromString(Me.FULLNAME.Text))
        Store_Cookie("Example_EMAIL", StripCodeFromString(Me.EMAIL.Text))
        'Store_Cookie("Example_COMBOBOX", StripCodeFromString(Me.COMBOBOX.SelectedValue))
        'Store_Cookie("Example_CHECKBOX", StripCodeFromString(Me.CHECKBOX.Checked.ToString()))
        'Store_Cookie("Example_LISTBOX", StripCodeFromString(Me.LISTBOX.SelectedValue))
        'Store_Cookie("Example_RADIOBUTTON", StripCodeFromString(Me.frmRadiobutton0.Checked.ToString()))

        ' SET FRAME
        cFDFDoc.FDFSetTargetFrame = "frame_examples"
        ' SET DOC JAVASCRIPT
        cFDFDoc.FDFSetOnImportJavaScript("var x = app.alert('Thank you for trying FDFToolkit.net!',3);", False)
        ' CLEAR THE OUTPUT STREAM
        Response.Clear()
        'Response.ContentType = cFDFApp.MimeTXT
        'Response.BinaryWrite(cFDFDoc.FDFSavetoBuf(FDFDoc_Class.FDFType.FDF, True))

        If Debug_Me Then
            Response.ContentType = cFDFApp.MimeTXT
        Else
            Response.ContentType = cFDFApp.MimePDF
        End If
        ' WRITE FDF FILE TO BUFFER
        Response.BinaryWrite(cFDFDoc.PDFMergeFDF2Buf(Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1) & "example.pdf", Me.frmPDF_Flatten.Checked))
        ' END RESPONSE
        Response.End()
    End Sub
End Class