'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.AcroFormsImportsGrapeCity.Documents.Pdf.AnnotationsImportsGrapeCity.Documents.Pdf.Actions '' This sample demonstrates how to create an AcroForm PDF that the user can submit.'' Here we submit it To the sample server, which receives the data and sends it back'' in a special form.PublicClassFormSubmitFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Dim page = doc.NewPage() Dim rc = Util.AddNote("In this sample the Submit button is associated with the ActionSubmitForm action, " +"with the URL pointing to a POST handler running on our sample server. " +"When the form is submitted, that handler receives a collection of form field names " +"and field values from the filled form, and sends it back in a simple HTML page. " +"If you download this sample, to successfully run it you will need to set up your own " +"handler, and change the Submit button action's URL to point to that handler.", page) Dim g = page.GraphicsDim tf = NewTextFormat() With {.Font = StandardFonts.Times, .FontSize = 14}Dim ip = NewPointF(72, rc.Bottom + 36)Dim fldOffset = 72.0F * 2 + 46Dim fldHeight = tf.FontSize * 1.2FDim dY = 32.0F '' Text field: g.DrawString("First name:", tf, ip)Dim fldFirstName = NewTextField() With {.Name = "FirstName", .Value = "John"} fldFirstName.Widget.Page = page fldFirstName.Widget.Rect = NewRectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight) fldFirstName.Widget.DefaultAppearance.Font = tf.Font fldFirstName.Widget.DefaultAppearance.FontSize = tf.FontSize doc.AcroForm.Fields.Add(fldFirstName) ip.Y += dY '' Text field: g.DrawString("Last name:", tf, ip)Dim fldLastName = NewTextField() With {.Name = "LastName", .Value = "Smith"} fldLastName.Widget.Page = page fldLastName.Widget.Rect = NewRectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight) fldLastName.Widget.DefaultAppearance.Font = tf.Font fldLastName.Widget.DefaultAppearance.FontSize = tf.FontSize doc.AcroForm.Fields.Add(fldLastName) ip.Y += dY '' Checkbox: g.DrawString("Subscribe to Mailing List:", tf, ip)Dim fldCheckbox = NewCheckBoxField() With {.Name = "Subscribe", .Checked = True} fldCheckbox.Widget.Page = page fldCheckbox.Widget.Rect = NewRectangleF(ip.X + fldOffset, ip.Y, fldHeight, fldHeight) doc.AcroForm.Fields.Add(fldCheckbox) ip.Y += dY '' Multiline TextBox: g.DrawString("Additional information:", tf, ip)Dim fldAdditionalInformation = NewTextField() With {.Name = "AdditionalInformation", .Multiline = True} fldAdditionalInformation.Widget.Page = page fldAdditionalInformation.Widget.Rect = NewRectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight * 2) fldAdditionalInformation.Widget.DefaultAppearance.Font = tf.Font fldAdditionalInformation.Widget.DefaultAppearance.FontSize = tf.FontSize doc.AcroForm.Fields.Add(fldAdditionalInformation) ip.Y += dY * 2 '' Submit form button:Dim btnSubmit = NewPushButtonField() btnSubmit.Widget.Rect = NewRectangleF(ip.X + fldOffset, ip.Y, 72, fldHeight) btnSubmit.Widget.ButtonAppearance.Caption = "Submit" btnSubmit.Widget.Highlighting = HighlightingMode.Invert btnSubmit.Widget.Page = page '' The URL for the submission: btnSubmit.Widget.Activate = NewActionSubmitForm("/Samples/HandleFormSubmitFields") doc.AcroForm.Fields.Add(btnSubmit) '' Reset form button:Dim btnReset = NewPushButtonField() btnReset.Widget.Rect = NewRectangleF(ip.X + fldOffset + 72 * 1.5F, ip.Y, 72, fldHeight) btnReset.Widget.ButtonAppearance.Caption = "Reset" btnReset.Widget.Highlighting = HighlightingMode.Invert btnReset.Widget.Activate = NewActionResetForm() btnReset.Widget.Page = page doc.AcroForm.Fields.Add(btnReset) ip.Y += dY'''' Done: doc.Save(stream)Return doc.Pages.CountEndFunctionEndClass