'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsSystem.TextImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.Pdf.AcroForms '' This sample loads the form created by the FormFields sample,'' loops through all form fields found in that file,'' and modifies the values of input fields.'' The log of what was done (showing old and new values) is added to the form page.PublicClassFillFormFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument() '' The original file stream must be kept open while working with the loaded PDF, see LoadPDF for details:Using fs AsNewFileStream(Path.Combine("Resources", "PDFs", "FormFields.pdf"), FileMode.Open, FileAccess.Read) doc.Load(fs)Dim page = doc.Pages.LastDim sb = NewStringBuilder() sb.AppendLine("Log of updates made by the FillForm sample:" + vbCrLf) ForEach fld In doc.AcroForm.FieldsIfTypeOf fld IsCombTextFieldThenDim ctfld = DirectCast(fld, CombTextField) sb.Append($"CombTextField.Value was '{ctfld.Value}', ") ctfld.Value = "Comb text" sb.AppendLine($"now '{ctfld.Value}'.")ElseIfTypeOf fld IsTextFieldThenDim tfld = DirectCast(fld, TextField) sb.Append($"TextField.Value was '{tfld.Value}', ") tfld.Value = $"Text updated on {Util.TimeNow():u}" sb.AppendLine($"now '{tfld.Value}'.")ElseIfTypeOf fld IsCheckBoxFieldThenDim cfld = DirectCast(fld, CheckBoxField) sb.Append($"CheckBoxField.Value was '{cfld.Checked}', ") cfld.Checked = Not cfld.Checked sb.AppendLine($"now '{cfld.Checked}'.")ElseIfTypeOf fld IsRadioButtonFieldThenDim rbfld = DirectCast(fld, RadioButtonField) sb.Append($"RadioButtonField.Value was '{rbfld.Value}', ") rbfld.Value = rbfld.Widgets.Count - 1 sb.AppendLine($"now '{rbfld.Value}'.")ElseIfTypeOf fld IsComboBoxFieldThenDim cmbfld = DirectCast(fld, ComboBoxField) sb.Append($"ComboBoxField selection was '{cmbfld.Items(cmbfld.SelectedIndex).Text}', ") cmbfld.SelectedIndex = cmbfld.Items.Count - 1 sb.AppendLine($"now '{cmbfld.Items(cmbfld.SelectedIndex).Text}'.")ElseIfTypeOf fld IsListBoxFieldThenDim lbfld = DirectCast(fld, ListBoxField) sb.Append($"ListBoxField selection was '{lbfld.Items(lbfld.SelectedIndex).Text}', ") lbfld.SelectedIndex = lbfld.Items.Count - 1 sb.AppendLine($"now '{lbfld.Items(lbfld.SelectedIndex).Text}'.")ElseIfTypeOf fld IsSignatureFieldThenDim sfld = DirectCast(fld, SignatureField) sb.AppendLine("SignatureField found.")ElseIfTypeOf fld IsPushButtonFieldThenDim btnfld = DirectCast(fld, PushButtonField) sb.AppendLine($"PushButtonField '{btnfld.Widget.ButtonAppearance.Caption}' found.")Else sb.AppendLine($"Field '{fld}' found/")EndIfNext'' Add a log of what we did at the bottom of the page:Dim tl = NewTextLayout(72) With { .MaxWidth = page.Size.Width, .MaxHeight = page.Size.Height, .MarginLeft = 80, .MarginRight = 80, .MarginBottom = 80, .ParagraphAlignment = ParagraphAlignment.Far } tl.Append(sb.ToString(), NewTextFormat() With {.Font = StandardFonts.Times, .FontSize = 12}) tl.PerformLayout(True)Dim rc = tl.ContentRectangle rc.Inflate(8, 8) page.Graphics.FillRectangle(rc, Color.LightYellow) page.Graphics.DrawRectangle(rc, Color.Orange) page.Graphics.DrawTextLayout(tl, PointF.Empty)'' Done: doc.Save(stream)EndUsing''Return doc.Pages.CountEndFunctionEndClass