From 726b4a9d81318a0d60d1d98da04f4bdb33fb6687 Mon Sep 17 00:00:00 2001 From: SF4524LogeshKumar Date: Mon, 8 Jun 2026 14:42:23 +0530 Subject: [PATCH 1/2] 1028844: Updated Sample for forms in Blazor PDF Viewer --- Form Designer/Components/Pages/AddButton.md | 25 ++++++++ Form Designer/Components/Pages/AddCheckBox.md | 26 ++++++++ .../Components/Pages/AddCustomData.md | 36 +++++++++++ Form Designer/Components/Pages/AddDropDown.md | 33 ++++++++++ Form Designer/Components/Pages/AddListBox.md | 33 ++++++++++ Form Designer/Components/Pages/AddPassword.md | 27 ++++++++ .../Components/Pages/AddRadioButton.md | 32 ++++++++++ .../Components/Pages/AddSignature.md | 26 ++++++++ Form Designer/Components/Pages/AddTextBox.md | 27 ++++++++ .../Components/Pages/ApplyFormFieldFlags.md | 45 +++++++++++++ .../Components/Pages/CustomizeTextBox.md | 36 +++++++++++ .../Pages/ExtractAllFormFieldValues.md | 44 +++++++++++++ .../ExtractFormDataAfterDocumentLoaded.md | 23 +++++++ .../Pages/FillFormFieldsProgrammatically.md | 43 +++++++++++++ .../Components/Pages/FlattenFormFields.md | 57 +++++++++++++++++ .../Components/Pages/GetAllFormFields.md | 20 ++++++ .../Components/Pages/GroupFormFields.md | 63 +++++++++++++++++++ .../Pages/ImportExportFormFieldData.md | 44 +++++++++++++ .../Components/Pages/MakeFieldsReadOnly.md | 43 +++++++++++++ .../Components/Pages/MarkFieldsRequired.md | 45 +++++++++++++ .../Components/Pages/MoveResizeFormFields.md | 62 ++++++++++++++++++ .../Pages/ReadCheckboxRadioButtonValues.md | 23 +++++++ .../Components/Pages/ReadCustomData.md | 29 +++++++++ .../Components/Pages/ReadDropdownValues.md | 54 ++++++++++++++++ .../Pages/ReadSignatureFieldData.md | 22 +++++++ .../Components/Pages/ReadTextFieldValues.md | 22 +++++++ .../Components/Pages/UpdateButton.md | 35 +++++++++++ .../Components/Pages/UpdateCheckBox.md | 33 ++++++++++ .../Components/Pages/UpdateCustomData.md | 39 ++++++++++++ .../Components/Pages/UpdateDropDown.md | 38 +++++++++++ .../Components/Pages/UpdateFormFieldFlags.md | 46 ++++++++++++++ .../Components/Pages/UpdateListBox.md | 38 +++++++++++ .../Components/Pages/UpdatePassword.md | 38 +++++++++++ .../Components/Pages/UpdateRadioButton.md | 32 ++++++++++ .../Components/Pages/UpdateSignature.md | 33 ++++++++++ .../Components/Pages/UpdateTextBox.md | 36 +++++++++++ .../Pages/ValidateFormFieldsOnSubmit.md | 41 ++++++++++++ 37 files changed, 1349 insertions(+) create mode 100644 Form Designer/Components/Pages/AddButton.md create mode 100644 Form Designer/Components/Pages/AddCheckBox.md create mode 100644 Form Designer/Components/Pages/AddCustomData.md create mode 100644 Form Designer/Components/Pages/AddDropDown.md create mode 100644 Form Designer/Components/Pages/AddListBox.md create mode 100644 Form Designer/Components/Pages/AddPassword.md create mode 100644 Form Designer/Components/Pages/AddRadioButton.md create mode 100644 Form Designer/Components/Pages/AddSignature.md create mode 100644 Form Designer/Components/Pages/AddTextBox.md create mode 100644 Form Designer/Components/Pages/ApplyFormFieldFlags.md create mode 100644 Form Designer/Components/Pages/CustomizeTextBox.md create mode 100644 Form Designer/Components/Pages/ExtractAllFormFieldValues.md create mode 100644 Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md create mode 100644 Form Designer/Components/Pages/FillFormFieldsProgrammatically.md create mode 100644 Form Designer/Components/Pages/FlattenFormFields.md create mode 100644 Form Designer/Components/Pages/GetAllFormFields.md create mode 100644 Form Designer/Components/Pages/GroupFormFields.md create mode 100644 Form Designer/Components/Pages/ImportExportFormFieldData.md create mode 100644 Form Designer/Components/Pages/MakeFieldsReadOnly.md create mode 100644 Form Designer/Components/Pages/MarkFieldsRequired.md create mode 100644 Form Designer/Components/Pages/MoveResizeFormFields.md create mode 100644 Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md create mode 100644 Form Designer/Components/Pages/ReadCustomData.md create mode 100644 Form Designer/Components/Pages/ReadDropdownValues.md create mode 100644 Form Designer/Components/Pages/ReadSignatureFieldData.md create mode 100644 Form Designer/Components/Pages/ReadTextFieldValues.md create mode 100644 Form Designer/Components/Pages/UpdateButton.md create mode 100644 Form Designer/Components/Pages/UpdateCheckBox.md create mode 100644 Form Designer/Components/Pages/UpdateCustomData.md create mode 100644 Form Designer/Components/Pages/UpdateDropDown.md create mode 100644 Form Designer/Components/Pages/UpdateFormFieldFlags.md create mode 100644 Form Designer/Components/Pages/UpdateListBox.md create mode 100644 Form Designer/Components/Pages/UpdatePassword.md create mode 100644 Form Designer/Components/Pages/UpdateRadioButton.md create mode 100644 Form Designer/Components/Pages/UpdateSignature.md create mode 100644 Form Designer/Components/Pages/UpdateTextBox.md create mode 100644 Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md diff --git a/Form Designer/Components/Pages/AddButton.md b/Form Designer/Components/Pages/AddButton.md new file mode 100644 index 00000000..6bb498d0 --- /dev/null +++ b/Form Designer/Components/Pages/AddButton.md @@ -0,0 +1,25 @@ +@page "/add-button" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddButtonField() + { + // Create a button field with properties + ButtonField buttonField = new ButtonField() + { + Name = "SubmitButton", + Bounds = new Bound() { X = 100, Y = 190, Width = 150, Height = 40 }, + TooltipText = "Click to submit the form" + }; + + // Add the button field to the PDF document + await viewer.AddFormFieldsAsync(new List { buttonField }); + } +} diff --git a/Form Designer/Components/Pages/AddCheckBox.md b/Form Designer/Components/Pages/AddCheckBox.md new file mode 100644 index 00000000..d7a90c05 --- /dev/null +++ b/Form Designer/Components/Pages/AddCheckBox.md @@ -0,0 +1,26 @@ +@page "/add-checkbox" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddCheckBoxField() + { + // Create a checkbox field with properties + CheckBoxField checkBoxField = new CheckBoxField() + { + Name = "AgreeTerms", + Bounds = new Bound() { X = 100, Y = 230, Width = 18, Height = 18 }, + IsChecked = false, + TooltipText = "I agree to the terms" + }; + + // Add the checkbox field to the PDF document + await viewer.AddFormFieldsAsync(new List { checkBoxField }); + } +} diff --git a/Form Designer/Components/Pages/AddCustomData.md b/Form Designer/Components/Pages/AddCustomData.md new file mode 100644 index 00000000..a0cdbc5d --- /dev/null +++ b/Form Designer/Components/Pages/AddCustomData.md @@ -0,0 +1,36 @@ +@page "/add-custom-data" +@using Syncfusion.Blazor.SfPdfViewer +@using System.Collections.Generic + + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task AddFormFieldsWithCustomData() + { + if (viewer == null) return; + + // Define custom metadata + var customMetadata = new Dictionary + { + { "businessId", "C-1024" }, + { "tags", new[] { "profile", "kiosk" } }, + { "requiredRole", "admin" } + }; + + // Create a TextBox field with custom data + var textField = new TextBoxField + { + Name = "Email", + CustomData = customMetadata, + Bounds = new Bound { X = 146, Y = 229, Width = 200, Height = 24 } + }; + + // Add the field to the document + await viewer.AddFormFieldsAsync(new List { textField }); + } +} diff --git a/Form Designer/Components/Pages/AddDropDown.md b/Form Designer/Components/Pages/AddDropDown.md new file mode 100644 index 00000000..b2bfab92 --- /dev/null +++ b/Form Designer/Components/Pages/AddDropDown.md @@ -0,0 +1,33 @@ +@page "/add-dropdown" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddDropDownField() + { + // Create list items for the dropdown + List options = new List() + { + new ListItem() { Name = "Item 1", Value = "item1" }, + new ListItem() { Name = "Item 2", Value = "item2" }, + new ListItem() { Name = "Item 3", Value = "item3" } + }; + + // Create a dropdown field with items + DropDownField dropDownField = new DropDownField() + { + Name = "Country", + Bounds = new Bound() { X = 560, Y = 320, Width = 150, Height = 24 }, + Items = options + }; + + // Add the dropdown field to the PDF document + await viewer.AddFormFieldsAsync(new List { dropDownField }); + } +} diff --git a/Form Designer/Components/Pages/AddListBox.md b/Form Designer/Components/Pages/AddListBox.md new file mode 100644 index 00000000..39fc82f0 --- /dev/null +++ b/Form Designer/Components/Pages/AddListBox.md @@ -0,0 +1,33 @@ +@page "/add-listbox" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddListBoxField() + { + // Create list items for the list box + List items = new List() + { + new ListItem() { Name = "Item 1", Value = "item1" }, + new ListItem() { Name = "Item 2", Value = "item2" }, + new ListItem() { Name = "Item 3", Value = "item3" } + }; + + // Create a list box field with items + ListBoxField listBoxField = new ListBoxField() + { + Name = "States", + Bounds = new Bound() { X = 100, Y = 310, Width = 220, Height = 70 }, + Items = items + }; + + // Add the list box field to the PDF document + await viewer.AddFormFieldsAsync(new List { listBoxField }); + } +} diff --git a/Form Designer/Components/Pages/AddPassword.md b/Form Designer/Components/Pages/AddPassword.md new file mode 100644 index 00000000..a789a8dd --- /dev/null +++ b/Form Designer/Components/Pages/AddPassword.md @@ -0,0 +1,27 @@ +@page "/add-password" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddPasswordField() + { + // Create a password field with properties + PasswordField passwordField = new PasswordField() + { + Name = "AccountPassword", + Bounds = new Bound() { X = 100, Y = 190, Width = 200, Height = 24 }, + IsRequired = true, + MaxLength = 32, + TooltipText = "Enter a secure password" + }; + + // Add the password field to the PDF document + await viewer.AddFormFieldsAsync(new List { passwordField }); + } +} diff --git a/Form Designer/Components/Pages/AddRadioButton.md b/Form Designer/Components/Pages/AddRadioButton.md new file mode 100644 index 00000000..8b6df5cd --- /dev/null +++ b/Form Designer/Components/Pages/AddRadioButton.md @@ -0,0 +1,32 @@ +@page "/add-radiobutton" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddRadioButtonFields() + { + // Create radio button fields grouped by name 'Gender' + RadioButtonField maleRadioButton = new RadioButtonField() + { + Name = "Gender", + Value = "Male", + Bounds = new Bound() { X = 100, Y = 270, Width = 16, Height = 16 } + }; + + RadioButtonField femaleRadioButton = new RadioButtonField() + { + Name = "Gender", + Value = "Female", + Bounds = new Bound() { X = 160, Y = 270, Width = 16, Height = 16 } + }; + + // Add the radio button fields to the PDF document + await viewer.AddFormFieldsAsync(new List { maleRadioButton, femaleRadioButton }); + } +} diff --git a/Form Designer/Components/Pages/AddSignature.md b/Form Designer/Components/Pages/AddSignature.md new file mode 100644 index 00000000..05ba490e --- /dev/null +++ b/Form Designer/Components/Pages/AddSignature.md @@ -0,0 +1,26 @@ +@page "/add-signature" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddSignatureField() + { + // Create a signature field + SignatureField signatureField = new SignatureField() + { + Name = "Sign", + Bounds = new Bound() { X = 57, Y = 923, Width = 200, Height = 43 }, + TooltipText = "sign Here", + IsRequired = true + }; + + // Add the signature field to the PDF document + await viewer.AddFormFieldsAsync(new List { signatureField }); + } +} diff --git a/Form Designer/Components/Pages/AddTextBox.md b/Form Designer/Components/Pages/AddTextBox.md new file mode 100644 index 00000000..9babf8c0 --- /dev/null +++ b/Form Designer/Components/Pages/AddTextBox.md @@ -0,0 +1,27 @@ +@page "/add-textbox" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + + private async Task AddTextBox() + { + // Create a text box field with properties + TextBoxField textBoxField = new TextBoxField() + { + Name = "FirstName", + Bounds = new Bound() { X = 100, Y = 150, Width = 200, Height = 24 }, + IsRequired = true, + TooltipText = "Enter your first name", + MaxLength = 40 + }; + + // Add the text box field to the PDF document + await viewer.AddFormFieldsAsync(new List { textBoxField }); + } +} \ No newline at end of file diff --git a/Form Designer/Components/Pages/ApplyFormFieldFlags.md b/Form Designer/Components/Pages/ApplyFormFieldFlags.md new file mode 100644 index 00000000..c081224b --- /dev/null +++ b/Form Designer/Components/Pages/ApplyFormFieldFlags.md @@ -0,0 +1,45 @@ +@page "/apply-form-field-flags" +@using Syncfusion.Blazor.SfPdfViewer + + + + + + +@code { + // Reference to the PDF Viewer instance + private SfPdfViewer2? viewer; + + // Path to the PDF document to be loaded in the viewer + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + // Method triggered when the document is loaded + private async Task OnDocumentLoaded() + { + if (viewer == null) return; + + var formFields = new List + { + // Read-only Textbox that is not required + new TextBoxField + { + Name = "EmployeeId", + Bounds = new Bound { X = 146, Y = 229, Width = 150, Height = 24 }, + IsReadOnly = true, + IsRequired = false, + Value = "EMP-0001" + }, + // Required Signature field + new SignatureField + { + Name = "ApplicantSign", + Bounds = new Bound { X = 57, Y = 923, Width = 200, Height = 43 }, + IsReadOnly = false, + IsRequired = true, + TooltipText = "Sign to accept the terms" + } + }; + + await viewer.AddFormFieldsAsync(formFields); + } +} diff --git a/Form Designer/Components/Pages/CustomizeTextBox.md b/Form Designer/Components/Pages/CustomizeTextBox.md new file mode 100644 index 00000000..0ca05314 --- /dev/null +++ b/Form Designer/Components/Pages/CustomizeTextBox.md @@ -0,0 +1,36 @@ +@page "/customize-textbox" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Apply Textbox Changes + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnEditTextbox() + { + if (viewer == null) return; + + List fields = await viewer.GetFormFieldsAsync(); + + var field = fields?.FirstOrDefault(f => f.Name == "FirstName"); + + if (field != null) + { + (field as TextBoxField).Value = "John"; + field.FontFamily = "Courier"; + field.FontSize = 12; + field.Color = "black"; + field.BackgroundColor = "white"; + field.BorderColor = "black"; + field.Thickness = 2; + field.TextAlignment = TextAlignment.Left; + + await viewer.UpdateFormFieldsAsync(new List { field }); + } + } +} \ No newline at end of file diff --git a/Form Designer/Components/Pages/ExtractAllFormFieldValues.md b/Form Designer/Components/Pages/ExtractAllFormFieldValues.md new file mode 100644 index 00000000..e3da6a6d --- /dev/null +++ b/Form Designer/Components/Pages/ExtractAllFormFieldValues.md @@ -0,0 +1,44 @@ +@page "/extract-all-form-field-values" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + + + + +Extract All Values + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-document.pdf"; + + private async Task ExtractAllFieldValues() + { + if (viewer == null) return; + var formFields = await viewer.GetFormFieldsAsync(); + + foreach (var field in formFields) + { + if (field is CheckBoxField checkBoxField) + { + Console.WriteLine($"{field.Name}: {checkBoxField.IsChecked}"); + } + else if (field is RadioButtonField radioButtonField) + { + Console.WriteLine($"{field.Name}: {radioButtonField.IsSelected}"); + } + else if (field is TextBoxField textBoxField) + { + Console.WriteLine($"{field.Name}: {textBoxField.Value}"); + } + else if (field is DropDownField dropDownField) + { + var selectedItem = dropDownField.Items.ElementAtOrDefault(dropDownField.SelectedIndex); + Console.WriteLine($"{field.Name}: {selectedItem?.Value}"); + } + else + { + Console.WriteLine($"{field.Name}: (unknown type)"); + } + } + } +} diff --git a/Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md b/Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md new file mode 100644 index 00000000..99bfd068 --- /dev/null +++ b/Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md @@ -0,0 +1,23 @@ +@page "/extract-form-data-after-document-loaded" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-document.pdf"; + + private async Task OnDocumentLoaded() + { + if (viewer == null) return; + + // Access form data right after the PDF loads + var formFields = await viewer.GetFormFieldsAsync(); + var emailField = formFields.FirstOrDefault(field => field is TextBoxField && field.Name == "email") as TextBoxField; + string email = emailField?.Value ?? string.Empty; + + Console.WriteLine($"Email: {email}"); + } +} diff --git a/Form Designer/Components/Pages/FillFormFieldsProgrammatically.md b/Form Designer/Components/Pages/FillFormFieldsProgrammatically.md new file mode 100644 index 00000000..d24a39e3 --- /dev/null +++ b/Form Designer/Components/Pages/FillFormFieldsProgrammatically.md @@ -0,0 +1,43 @@ +@page "/fill-form-fields-programmatically" +@using Syncfusion.Blazor.SfPdfViewer + + + + + + +@code { + SfPdfViewer2? pdfViewer; + + async Task UpdateFormFields() + { + if (pdfViewer == null) + return; + + // Get fields + List formFields = await pdfViewer.GetFormFieldsAsync(); + + if (formFields == null || formFields.Count == 0) + return; + + // Find textbox safely + var textField = formFields + .OfType() + .FirstOrDefault(f => f.Name == "name") + ?? formFields.OfType().FirstOrDefault(); + + if (textField != null) + { + textField.Value = "John Doe"; + textField.TooltipText = "First Name"; + + // Update using SAME TYPE (FormFieldInfo) + await pdfViewer.UpdateFormFieldsAsync(new List() + { + textField + }); + } + } +} diff --git a/Form Designer/Components/Pages/FlattenFormFields.md b/Form Designer/Components/Pages/FlattenFormFields.md new file mode 100644 index 00000000..f5102170 --- /dev/null +++ b/Form Designer/Components/Pages/FlattenFormFields.md @@ -0,0 +1,57 @@ +@page "/flatten-form-fields" +@using Syncfusion.Blazor +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons +@using Syncfusion.Pdf +@using Syncfusion.Pdf.Parsing + +Flatten + + + + +@code { + private SfPdfViewer2? Viewer; + public string DocumentPath { get; set; } = "wwwroot/data/form-filling-document.pdf"; + + private async Task FlattenDownload() + { + if (Viewer is null) return; + + // Get current document from viewer as byte array + byte[] bytes = await Viewer.GetDocumentAsync(); + + // Load into PdfLoadedDocument for flattening + PdfLoadedDocument loadedDocument = new PdfLoadedDocument(bytes); + + // Flatten form fields + if (loadedDocument.Form != null) + { + loadedDocument.Form.Flatten = true; + } + + // Flatten annotations on all pages + foreach (PdfLoadedPage page in loadedDocument.Pages) + { + page.Annotations.Flatten = true; + } + + // Save flattened PDF to byte array + byte[] flattenedBytes; + using (MemoryStream stream = new MemoryStream()) + { + loadedDocument.Save(stream); + flattenedBytes = stream.ToArray(); + } + + loadedDocument.Close(true); + + // Reload flattened document into viewer + await Viewer.LoadAsync(flattenedBytes); + + // Download the flattened PDF + await Viewer.DownloadAsync(); + } +} diff --git a/Form Designer/Components/Pages/GetAllFormFields.md b/Form Designer/Components/Pages/GetAllFormFields.md new file mode 100644 index 00000000..24aec3be --- /dev/null +++ b/Form Designer/Components/Pages/GetAllFormFields.md @@ -0,0 +1,20 @@ +@page "/get-all-form-fields" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + + + + +Get Form Fields + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-document.pdf"; + + private async Task GetAllFormFields() + { + if (viewer == null) return; + var formFields = await viewer.GetFormFieldsAsync(); + Console.WriteLine($"Total form fields: {formFields.Count}"); + } +} diff --git a/Form Designer/Components/Pages/GroupFormFields.md b/Form Designer/Components/Pages/GroupFormFields.md new file mode 100644 index 00000000..199424a4 --- /dev/null +++ b/Form Designer/Components/Pages/GroupFormFields.md @@ -0,0 +1,63 @@ +@page "/group-form-fields" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnDocumentLoaded() + { + if (viewer == null) return; + + // Create grouped form fields with the same name + var formFields = new List + { + // Textbox group: same name => mirrored value + new TextBoxField + { + Name = "EmployeeId", + Bounds = new Bound { X = 146, Y = 229, Width = 150, Height = 24 } + }, + new TextBoxField + { + Name = "EmployeeId", // same name groups the two widgets + Bounds = new Bound { X = 338, Y = 229, Width = 150, Height = 24 } + }, + + // Radio button group: same name => exclusive selection across the group + new RadioButtonField + { + Name = "Gender", + Bounds = new Bound { X = 148, Y = 289, Width = 18, Height = 18 }, + IsSelected = false + }, + new RadioButtonField + { + Name = "Gender", // grouped with the first + Bounds = new Bound { X = 292, Y = 289, Width = 18, Height = 18 }, + IsSelected = false + }, + + // CheckBox group: same name => mirrored checked state + new CheckBoxField + { + Name = "Subscribe", + Bounds = new Bound { X = 56, Y = 664, Width = 20, Height = 20 }, + IsChecked = false + }, + new CheckBoxField + { + Name = "Subscribe", // grouped with the first + Bounds = new Bound { X = 242, Y = 664, Width = 20, Height = 20 }, + IsChecked = false + } + }; + + // Add the grouped form fields to the PDF document + await viewer.AddFormFieldsAsync(formFields); + } +} diff --git a/Form Designer/Components/Pages/ImportExportFormFieldData.md b/Form Designer/Components/Pages/ImportExportFormFieldData.md new file mode 100644 index 00000000..02787e0e --- /dev/null +++ b/Form Designer/Components/Pages/ImportExportFormFieldData.md @@ -0,0 +1,44 @@ +@page "/import-export-form-field-data" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Export Data +Import Data + + + + +@code { + // Reference to the SfPdfViewer2 instance + SfPdfViewer2 PdfViewerInstance { get; set; } + + // Stream to store exported form field data in FDF format + Stream FDFStream = new MemoryStream(); + + // List to store form field information + List FormFields = new List(); + + // Exports form field data from the PDF viewer in FDF format + private async void ExportFormFieldData() + { + // Retrieve form field information from the PDF viewer + FormFields = await PdfViewerInstance.GetFormFieldsAsync(); + if (FormFields != null && FormFields.Count > 0) + { + // Export form fields as FDF data + FDFStream = await PdfViewerInstance.ExportFormFieldsAsync(FormFieldDataFormat.Fdf); + } + } + + // Imports form field data from FDF format into the PDF viewer + private async void ImportFormFieldData() + { + if (FDFStream != null) + { + // Import FDF data into the viewer + await PdfViewerInstance.ImportFormFieldsAsync(FDFStream, FormFieldDataFormat.Fdf); + } + } +} diff --git a/Form Designer/Components/Pages/MakeFieldsReadOnly.md b/Form Designer/Components/Pages/MakeFieldsReadOnly.md new file mode 100644 index 00000000..e23e5c0e --- /dev/null +++ b/Form Designer/Components/Pages/MakeFieldsReadOnly.md @@ -0,0 +1,43 @@ +@page "/make-fields-readonly" +@using Syncfusion.Blazor.SfPdfViewer + + + + + + +@code { + // Reference to the PDF Viewer instance + private SfPdfViewer2? viewer; + + // Path to the PDF document to be loaded in the viewer + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + // Method triggered when the document is loaded + private async Task OnDocumentLoaded() + { + if (viewer == null) return; + + var formFields = new List + { + // Read-only Textbox + new TextBoxField + { + Name = "EmployeeId", + Bounds = new Bound { X = 146, Y = 229, Width = 150, Height = 24 }, + IsReadOnly = true, + Value = "EMP-0001" + }, + // Read-only Signature field + new SignatureField + { + Name = "ApplicantSign", + Bounds = new Bound { X = 57, Y = 923, Width = 200, Height = 43 }, + IsReadOnly = true, + TooltipText = "Sign to accept the terms" + } + }; + + await viewer.AddFormFieldsAsync(formFields); + } +} diff --git a/Form Designer/Components/Pages/MarkFieldsRequired.md b/Form Designer/Components/Pages/MarkFieldsRequired.md new file mode 100644 index 00000000..045ff747 --- /dev/null +++ b/Form Designer/Components/Pages/MarkFieldsRequired.md @@ -0,0 +1,45 @@ +@page "/mark-fields-required" +@using Syncfusion.Blazor.SfPdfViewer + + + + + + +@code { + // Reference to the PDF Viewer instance + private SfPdfViewer2? viewer; + + // Path to the PDF document to be loaded in the viewer + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + // Method triggered when the document is loaded + private async Task OnDocumentLoaded() + { + if (viewer == null) return; + + var formFields = new List + { + new TextBoxField + { + Name = "Email", + Bounds = new Bound { X = 146, Y = 260, Width = 220, Height = 24 }, + IsRequired = true, + TooltipText = "Email is required" + } + }; + + await viewer.AddFormFieldsAsync(formFields); + } + + // Validation event handler + private void OnValidateFormFields(ValidateFormFieldsArgs args) + { + Dictionary unfilledFields = args.UnfilledFields; + foreach (var field in unfilledFields) + { + Console.WriteLine($"Field Name: {field.Key}, Default Value: {field.Value}"); + // Further processing of unfilled fields + } + } +} diff --git a/Form Designer/Components/Pages/MoveResizeFormFields.md b/Form Designer/Components/Pages/MoveResizeFormFields.md new file mode 100644 index 00000000..6a4cc6c5 --- /dev/null +++ b/Form Designer/Components/Pages/MoveResizeFormFields.md @@ -0,0 +1,62 @@ +@page "/move-resize-form-fields" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Add Form Fields +Resize and Move "First Name" + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnAddFormFields() + { + if (viewer == null) return; + + // Create form fields with initial bounds + var formFields = new List + { + new TextBoxField + { + Name = "FirstName", + Bounds = new Bound { X = 146, Y = 229, Width = 150, Height = 24 } + }, + new PasswordField + { + Name = "Password", + Bounds = new Bound { X = 338, Y = 229, Width = 150, Height = 24 } + }, + new SignatureField + { + Name = "SignHere", + Bounds = new Bound { X = 146, Y = 280, Width = 200, Height = 43 } + } + }; + + // Add the form fields to the PDF document + await viewer.AddFormFieldsAsync(formFields); + } + + private async Task OnResizeAndMove() + { + if (viewer == null) return; + + // Retrieve all form fields from the PDF + List fields = await viewer.GetFormFieldsAsync(); + + // Find the "First Name" field + var field = fields?.FirstOrDefault(f => f.Name == "FirstName"); + + if (field != null) + { + // Update the bounds (move and resize) + field.Bounds = new Bound { X = 140, Y = 210, Width = 220, Height = 24 }; + + // Apply the changes + await viewer.UpdateFormFieldsAsync(new List { field }); + } + } +} diff --git a/Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md b/Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md new file mode 100644 index 00000000..45dac987 --- /dev/null +++ b/Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md @@ -0,0 +1,23 @@ +@page "/read-checkbox-radiobutton-values" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + + + + +Read Checkbox Values + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-document.pdf"; + + private async Task ReadCheckboxValues() + { + if (viewer == null) return; + var formFields = await viewer.GetFormFieldsAsync(); + var radioButtons = formFields.OfType().Where(field => field.Name == "gender").ToList(); + var checkedField = radioButtons.FirstOrDefault(field => field.IsSelected); + string fieldName = checkedField?.Name ?? string.Empty; + Console.WriteLine($"Selected radio button: {fieldName}"); + } +} diff --git a/Form Designer/Components/Pages/ReadCustomData.md b/Form Designer/Components/Pages/ReadCustomData.md new file mode 100644 index 00000000..60bcad54 --- /dev/null +++ b/Form Designer/Components/Pages/ReadCustomData.md @@ -0,0 +1,29 @@ +@page "/read-custom-data" +@using Syncfusion.Blazor.SfPdfViewer + + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnDocumentLoaded() + { + if (viewer == null) return; + + // Get all form fields + var fields = await viewer.GetFormFieldsAsync(); + + // Access custom data from each field + foreach (var field in fields) + { + Console.WriteLine($"Field: {field.Name}"); + if (field.CustomData != null) + { + Console.WriteLine($"Custom Data: {System.Text.Json.JsonSerializer.Serialize(field.CustomData)}"); + } + } + } +} diff --git a/Form Designer/Components/Pages/ReadDropdownValues.md b/Form Designer/Components/Pages/ReadDropdownValues.md new file mode 100644 index 00000000..83d432fc --- /dev/null +++ b/Form Designer/Components/Pages/ReadDropdownValues.md @@ -0,0 +1,54 @@ +@page "/read-dropdown-values" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + + + + +Read Dropdown Value + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-document.pdf"; + + private async Task ReadDropdownValues() + { + if (viewer == null) return; + + try + { + var formFields = await viewer.GetFormFieldsAsync(); + var dropdownField = formFields?.FirstOrDefault(field => field is DropDownField && field.Name == "state") as DropDownField; + + if (dropdownField != null && dropdownField.Items != null && dropdownField.Items.Count > 0) + { + // Read ALL values in dropdown + Console.WriteLine("=== All Dropdown Values ==="); + for (int i = 0; i < dropdownField.Items.Count; i++) + { + Console.WriteLine($"Index {i}: Name = {dropdownField.Items[i].Name}, Value = {dropdownField.Items[i].Value}"); + } + + // Get selected item using SelectedIndex + int selectedIndex = dropdownField.SelectedIndex; + string selectedValue = selectedIndex >= 0 ? dropdownField.Items[selectedIndex].Value : string.Empty; + Console.WriteLine($"\nCurrently Selected: Index={selectedIndex}, Value={selectedValue}"); + + // Update dropdown with new items + dropdownField.Items = new List + { + new ListItem { Name = "USA", Value = "US" }, + new ListItem { Name = "Canada", Value = "CA" }, + new ListItem { Name = "Mexico", Value = "MX" } + }; + dropdownField.SelectedIndex = 0; // Set default selection + + await viewer.UpdateFormFieldsAsync(new List { dropdownField }); + } + } + catch (Exception ex) + { + Console.WriteLine($"Error: {ex.Message}"); + } + } +} diff --git a/Form Designer/Components/Pages/ReadSignatureFieldData.md b/Form Designer/Components/Pages/ReadSignatureFieldData.md new file mode 100644 index 00000000..79d0f6cb --- /dev/null +++ b/Form Designer/Components/Pages/ReadSignatureFieldData.md @@ -0,0 +1,22 @@ +@page "/read-signature-field-data" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + + + + +Read Signature Data + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-document.pdf"; + + private async Task ReadSignatureData() + { + if (viewer == null) return; + var formFields = await viewer.GetFormFieldsAsync(); + var signatureField = formFields.FirstOrDefault(field => field is SignatureField && field.Name == "signature") as SignatureField; + string signatureData = signatureField?.Value ?? string.Empty; + Console.WriteLine($"Signature data: {signatureData}"); + } +} diff --git a/Form Designer/Components/Pages/ReadTextFieldValues.md b/Form Designer/Components/Pages/ReadTextFieldValues.md new file mode 100644 index 00000000..c689f12c --- /dev/null +++ b/Form Designer/Components/Pages/ReadTextFieldValues.md @@ -0,0 +1,22 @@ +@page "/read-text-field-values" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + + + + +Read Text Field + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-document.pdf"; + + private async Task ReadTextFields() + { + if (viewer == null) return; + var formFields = await viewer.GetFormFieldsAsync(); + var nameField = formFields.FirstOrDefault(field => field is TextBoxField && field.Name == "name") as TextBoxField; + string nameValue = nameField?.Value ?? string.Empty; + Console.WriteLine($"Name field value: {nameValue}"); + } +} diff --git a/Form Designer/Components/Pages/UpdateButton.md b/Form Designer/Components/Pages/UpdateButton.md new file mode 100644 index 00000000..763cb2b6 --- /dev/null +++ b/Form Designer/Components/Pages/UpdateButton.md @@ -0,0 +1,35 @@ +@page "/update-button" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Edit Button + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnEditButton() + { + if (viewer == null) return; + + List fields = await viewer.GetFormFieldsAsync(); + + var field = fields?.FirstOrDefault(f => f.Name == "SubmitButton"); + + if (field != null) + { + field.BackgroundColor = "#008000"; + field.Color = "white"; + field.FontFamily = "Arial"; + field.FontSize = 12; + field.BorderColor = "black"; + field.Thickness = 2; + field.TooltipText = "Click to submit"; + + await viewer.UpdateFormFieldsAsync(new List { field }); + } + } +} diff --git a/Form Designer/Components/Pages/UpdateCheckBox.md b/Form Designer/Components/Pages/UpdateCheckBox.md new file mode 100644 index 00000000..b5cd44cd --- /dev/null +++ b/Form Designer/Components/Pages/UpdateCheckBox.md @@ -0,0 +1,33 @@ +@page "/update-checkbox" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Edit CheckBox + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnEditCheckbox() + { + if (viewer == null) return; + + List fields = await viewer.GetFormFieldsAsync(); + + var cb = fields?.FirstOrDefault(f => f.Name == "Subscribe"); + + if (cb != null) + { + (cb as CheckBoxField).IsChecked = true; + cb.BackgroundColor = "white"; + cb.BorderColor = "black"; + cb.Thickness = 2; + cb.TooltipText = "Subscribe to newsletter"; + + await viewer.UpdateFormFieldsAsync(new List { cb }); + } + } +} diff --git a/Form Designer/Components/Pages/UpdateCustomData.md b/Form Designer/Components/Pages/UpdateCustomData.md new file mode 100644 index 00000000..5aed7771 --- /dev/null +++ b/Form Designer/Components/Pages/UpdateCustomData.md @@ -0,0 +1,39 @@ +@page "/update-custom-data" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons +@using System.Collections.Generic + +Update First Field Custom Data + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task UpdateFirstFieldCustomData() + { + if (viewer == null) return; + + // Get all form fields + var fields = await viewer.GetFormFieldsAsync(); + if (fields.Count == 0) return; + + // Get the first field + var targetField = fields[0]; + + // Update custom data + var updatedCustomData = new Dictionary + { + { "group", "profile" }, + { "flags", new[] { "pii", "masked" } }, + { "updatedAt", DateTime.Now.Ticks } + }; + + targetField.CustomData = updatedCustomData; + + // Update the field + await viewer.UpdateFormFieldsAsync(new List { targetField }); + } +} diff --git a/Form Designer/Components/Pages/UpdateDropDown.md b/Form Designer/Components/Pages/UpdateDropDown.md new file mode 100644 index 00000000..83466828 --- /dev/null +++ b/Form Designer/Components/Pages/UpdateDropDown.md @@ -0,0 +1,38 @@ +@page "/update-dropdown" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Edit DropDown + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/formDesigner_Document.pdf"; + + private async Task UpdateFormField() + { + if (viewer == null) return; + + List formFields = await viewer.GetFormFieldsAsync(); + + // Find only the specific dropdown by name + var dropDown = formFields?.FirstOrDefault(f => f.Name == "CountryDropdown" && f is DropDownField) as DropDownField; + if (dropDown != null) + { + dropDown.Items = new List { + new ListItem { Name = "option 1", Value = "Option 1" }, + new ListItem { Name = "option 2", Value = "Option 2" }, + new ListItem { Name = "option 3", Value = "Option 3" } + }; + dropDown.FontFamily = "Courier"; + dropDown.FontSize = 10; + dropDown.Color = "black"; + dropDown.BorderColor = "black"; + dropDown.BackgroundColor = "white"; + + await viewer.UpdateFormFieldsAsync(new List { dropDown }); + } + } +} diff --git a/Form Designer/Components/Pages/UpdateFormFieldFlags.md b/Form Designer/Components/Pages/UpdateFormFieldFlags.md new file mode 100644 index 00000000..dfa8cac3 --- /dev/null +++ b/Form Designer/Components/Pages/UpdateFormFieldFlags.md @@ -0,0 +1,46 @@ +@page "/update-form-field-flags" +@using Syncfusion.Blazor.SfPdfViewer + + + + + + +@code { + // Reference to the PDF Viewer instance + private SfPdfViewer2? viewer; + + // Path to the PDF document to be loaded in the viewer + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + // Method triggered when the document is loaded + private async Task OnDocumentLoaded() + { + if (viewer == null) return; + + // 1) Add a sample textbox + var formFields = new List + { + new TextBoxField + { + Name = "Email", + Bounds = new Bound { X = 146, Y = 260, Width = 220, Height = 24 } + } + }; + + await viewer.AddFormFieldsAsync(formFields); + + // 2) Retrieve and update constraint flags + var allFields = await viewer.GetFormFieldsAsync(); + var field = allFields.FirstOrDefault(f => f.Name == "Email"); + + if (field is TextBoxField emailField) + { + emailField.IsReadOnly = false; + emailField.IsRequired = true; + emailField.TooltipText = "Enter a valid email"; + + await viewer.UpdateFormFieldsAsync(new List { emailField }); + } + } +} diff --git a/Form Designer/Components/Pages/UpdateListBox.md b/Form Designer/Components/Pages/UpdateListBox.md new file mode 100644 index 00000000..39987bee --- /dev/null +++ b/Form Designer/Components/Pages/UpdateListBox.md @@ -0,0 +1,38 @@ +@page "/update-listbox" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Edit ListBox + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/formDesigner_Document.pdf"; + + private async Task UpdateFormField() + { + if (viewer == null) return; + + List formFields = await viewer.GetFormFieldsAsync(); + + // Find and update ListBoxField + var listBox = formFields?.FirstOrDefault(f => f.Name == "InterestListBox" && f is ListBoxField) as ListBoxField; + if (listBox != null) + { + listBox.Items = new List { + new ListItem { Name = "item 1", Value = "Item 1" }, + new ListItem { Name = "item 2", Value = "Item 2" }, + new ListItem { Name = "item 3", Value = "Item 3" } + }; + listBox.FontFamily = "Courier"; + listBox.FontSize = 10; + listBox.Color = "black"; + listBox.BorderColor = "black"; + listBox.BackgroundColor = "white"; + + await viewer.UpdateFormFieldsAsync(new List { listBox }); + } + } +} diff --git a/Form Designer/Components/Pages/UpdatePassword.md b/Form Designer/Components/Pages/UpdatePassword.md new file mode 100644 index 00000000..84a62d84 --- /dev/null +++ b/Form Designer/Components/Pages/UpdatePassword.md @@ -0,0 +1,38 @@ +@page "/update-password" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Edit PasswordBox + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnEditPassword() + { + if (viewer == null) return; + + List fields = await viewer.GetFormFieldsAsync(); + + var field = fields?.FirstOrDefault(f => f.Name == "Password"); + + if (field != null) + { + (field as PasswordField).TooltipText = "Enter your password"; + field.IsReadOnly = false; + field.IsRequired = true; + field.FontFamily = "Courier"; + field.FontSize = 10; + field.Color = "black"; + field.BorderColor = "black"; + field.BackgroundColor = "white"; + field.TextAlignment = TextAlignment.Left; + field.Thickness = 1; + + await viewer.UpdateFormFieldsAsync(new List { field }); + } + } +} diff --git a/Form Designer/Components/Pages/UpdateRadioButton.md b/Form Designer/Components/Pages/UpdateRadioButton.md new file mode 100644 index 00000000..76fa0c32 --- /dev/null +++ b/Form Designer/Components/Pages/UpdateRadioButton.md @@ -0,0 +1,32 @@ +@page "/update-radiobutton" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Edit RadioButton + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnEditRadio() + { + if (viewer == null) return; + + List fields = await viewer.GetFormFieldsAsync(); + + var genderRadios = fields?.Where(f => f.Name == "Gender").ToList(); + + if (genderRadios?.Count > 1) + { + (genderRadios[0] as RadioButtonField).IsSelected = false; + (genderRadios[1] as RadioButtonField).IsSelected = true; + genderRadios[1].Thickness = 2; + genderRadios[1].BorderColor = "yellow"; + + await viewer.UpdateFormFieldsAsync(genderRadios); + } + } +} diff --git a/Form Designer/Components/Pages/UpdateSignature.md b/Form Designer/Components/Pages/UpdateSignature.md new file mode 100644 index 00000000..78356468 --- /dev/null +++ b/Form Designer/Components/Pages/UpdateSignature.md @@ -0,0 +1,33 @@ +@page "/update-signature" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Edit Signature + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnEditSignature() + { + if (viewer == null) return; + + List fields = await viewer.GetFormFieldsAsync(); + + var sig = fields?.FirstOrDefault(f => f.Name == "Sign"); + + if (sig != null) + { + sig.TooltipText = "Please sign here"; + sig.Thickness = 3; + sig.IsRequired = true; + sig.BackgroundColor = "white"; + sig.BorderColor = "black"; + + await viewer.UpdateFormFieldsAsync(new List { sig }); + } + } +} diff --git a/Form Designer/Components/Pages/UpdateTextBox.md b/Form Designer/Components/Pages/UpdateTextBox.md new file mode 100644 index 00000000..6e67e45b --- /dev/null +++ b/Form Designer/Components/Pages/UpdateTextBox.md @@ -0,0 +1,36 @@ +@page "/update-textbox" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + +Apply Textbox Changes + + + + +@code { + private SfPdfViewer2? viewer; + private string DocumentPath = "wwwroot/data/form-designer.pdf"; + + private async Task OnEditTextbox() + { + if (viewer == null) return; + + List fields = await viewer.GetFormFieldsAsync(); + + var field = fields?.FirstOrDefault(f => f.Name == "FirstName"); + + if (field != null) + { + (field as TextBoxField).Value = "John"; + field.FontFamily = "Courier"; + field.FontSize = 12; + field.Color = "black"; + field.BackgroundColor = "white"; + field.BorderColor = "black"; + field.Thickness = 2; + field.TextAlignment = TextAlignment.Left; + + await viewer.UpdateFormFieldsAsync(new List { field }); + } + } +} diff --git a/Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md b/Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md new file mode 100644 index 00000000..108cb785 --- /dev/null +++ b/Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md @@ -0,0 +1,41 @@ +@page "/validate-form-fields-on-submit" +@using Syncfusion.Blazor.SfPdfViewer +@using Syncfusion.Blazor.Buttons + + + + + +@code { + SfPdfViewer2 Viewer; + + // Method triggered when the document is loaded + private async Task AddFormFields() + { + // Define various form fields with their properties and positions + List formFields = new List + { + new TextBoxField { Name = "TextBox Field", Bounds = new Bound { X = 278, Y = 247, Width = 200, Height = 24 }, IsRequired = true }, + new PasswordField { Name = "Password Field", Bounds = new Bound { X = 278, Y = 323, Width = 200, Height = 24 }, IsRequired = true }, + new SignatureField { Name = "Signature Field", Bounds = new Bound { X = 278, Y = 686, Width = 200, Height = 63 }, IsRequired = true } + }; + + // Add form fields asynchronously to the PDF Viewer + await Viewer.AddFormFieldsAsync(formFields); + } + + // Validation event handler + private void OnValidateFormFields(ValidateFormFieldsArgs args) + { + Dictionary unfilledFields = args.UnfilledFields; + foreach (var field in unfilledFields) + { + Console.WriteLine($"Field Name: {field.Key}, Default Value: {field.Value}"); + // Further processing of unfilled fields + } + } +} From 33af3222db4c510273b904461590d7e76156f0e5 Mon Sep 17 00:00:00 2001 From: SF4524LogeshKumar Date: Mon, 8 Jun 2026 16:49:40 +0530 Subject: [PATCH 2/2] 1028844: Updated proper Document Names and Data-types --- Form Designer/Components/Pages/AddButton.md | 2 +- Form Designer/Components/Pages/AddCheckBox.md | 2 +- Form Designer/Components/Pages/AddCustomData.md | 6 +++--- Form Designer/Components/Pages/AddDropDown.md | 2 +- Form Designer/Components/Pages/AddListBox.md | 2 +- Form Designer/Components/Pages/AddPassword.md | 2 +- Form Designer/Components/Pages/AddRadioButton.md | 2 +- Form Designer/Components/Pages/AddSignature.md | 2 +- Form Designer/Components/Pages/AddTextBox.md | 2 +- Form Designer/Components/Pages/ApplyFormFieldFlags.md | 4 ++-- Form Designer/Components/Pages/CustomizeTextBox.md | 4 ++-- .../Components/Pages/ExtractAllFormFieldValues.md | 8 ++++---- .../Pages/ExtractFormDataAfterDocumentLoaded.md | 6 +++--- .../Components/Pages/FillFormFieldsProgrammatically.md | 4 ++-- Form Designer/Components/Pages/FlattenFormFields.md | 2 +- Form Designer/Components/Pages/GetAllFormFields.md | 4 ++-- Form Designer/Components/Pages/GroupFormFields.md | 4 ++-- .../Components/Pages/ImportExportFormFieldData.md | 4 ++-- Form Designer/Components/Pages/MakeFieldsReadOnly.md | 4 ++-- Form Designer/Components/Pages/MarkFieldsRequired.md | 6 +++--- Form Designer/Components/Pages/MoveResizeFormFields.md | 6 +++--- .../Components/Pages/ReadCheckboxRadioButtonValues.md | 8 ++++---- Form Designer/Components/Pages/ReadCustomData.md | 6 +++--- Form Designer/Components/Pages/ReadDropdownValues.md | 6 +++--- Form Designer/Components/Pages/ReadSignatureFieldData.md | 6 +++--- Form Designer/Components/Pages/ReadTextFieldValues.md | 6 +++--- Form Designer/Components/Pages/UpdateButton.md | 4 ++-- Form Designer/Components/Pages/UpdateCheckBox.md | 4 ++-- Form Designer/Components/Pages/UpdateCustomData.md | 8 ++++---- Form Designer/Components/Pages/UpdateDropDown.md | 4 ++-- Form Designer/Components/Pages/UpdateFormFieldFlags.md | 8 ++++---- Form Designer/Components/Pages/UpdateListBox.md | 4 ++-- Form Designer/Components/Pages/UpdatePassword.md | 4 ++-- Form Designer/Components/Pages/UpdateRadioButton.md | 4 ++-- Form Designer/Components/Pages/UpdateSignature.md | 4 ++-- Form Designer/Components/Pages/UpdateTextBox.md | 4 ++-- .../Components/Pages/ValidateFormFieldsOnSubmit.md | 4 ++-- 37 files changed, 81 insertions(+), 81 deletions(-) diff --git a/Form Designer/Components/Pages/AddButton.md b/Form Designer/Components/Pages/AddButton.md index 6bb498d0..1a3e743d 100644 --- a/Form Designer/Components/Pages/AddButton.md +++ b/Form Designer/Components/Pages/AddButton.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddButtonField() { diff --git a/Form Designer/Components/Pages/AddCheckBox.md b/Form Designer/Components/Pages/AddCheckBox.md index d7a90c05..8a702604 100644 --- a/Form Designer/Components/Pages/AddCheckBox.md +++ b/Form Designer/Components/Pages/AddCheckBox.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddCheckBoxField() { diff --git a/Form Designer/Components/Pages/AddCustomData.md b/Form Designer/Components/Pages/AddCustomData.md index a0cdbc5d..f8e707c7 100644 --- a/Form Designer/Components/Pages/AddCustomData.md +++ b/Form Designer/Components/Pages/AddCustomData.md @@ -8,14 +8,14 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task AddFormFieldsWithCustomData() { if (viewer == null) return; // Define custom metadata - var customMetadata = new Dictionary + Dictionary customMetadata = new Dictionary { { "businessId", "C-1024" }, { "tags", new[] { "profile", "kiosk" } }, @@ -23,7 +23,7 @@ }; // Create a TextBox field with custom data - var textField = new TextBoxField + TextBoxField textField = new TextBoxField { Name = "Email", CustomData = customMetadata, diff --git a/Form Designer/Components/Pages/AddDropDown.md b/Form Designer/Components/Pages/AddDropDown.md index b2bfab92..bd83b361 100644 --- a/Form Designer/Components/Pages/AddDropDown.md +++ b/Form Designer/Components/Pages/AddDropDown.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddDropDownField() { diff --git a/Form Designer/Components/Pages/AddListBox.md b/Form Designer/Components/Pages/AddListBox.md index 39fc82f0..f1256cbc 100644 --- a/Form Designer/Components/Pages/AddListBox.md +++ b/Form Designer/Components/Pages/AddListBox.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddListBoxField() { diff --git a/Form Designer/Components/Pages/AddPassword.md b/Form Designer/Components/Pages/AddPassword.md index a789a8dd..2f84c2b7 100644 --- a/Form Designer/Components/Pages/AddPassword.md +++ b/Form Designer/Components/Pages/AddPassword.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddPasswordField() { diff --git a/Form Designer/Components/Pages/AddRadioButton.md b/Form Designer/Components/Pages/AddRadioButton.md index 8b6df5cd..c3eabc49 100644 --- a/Form Designer/Components/Pages/AddRadioButton.md +++ b/Form Designer/Components/Pages/AddRadioButton.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddRadioButtonFields() { diff --git a/Form Designer/Components/Pages/AddSignature.md b/Form Designer/Components/Pages/AddSignature.md index 05ba490e..b62a87b9 100644 --- a/Form Designer/Components/Pages/AddSignature.md +++ b/Form Designer/Components/Pages/AddSignature.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddSignatureField() { diff --git a/Form Designer/Components/Pages/AddTextBox.md b/Form Designer/Components/Pages/AddTextBox.md index 9babf8c0..a51e4ec3 100644 --- a/Form Designer/Components/Pages/AddTextBox.md +++ b/Form Designer/Components/Pages/AddTextBox.md @@ -7,7 +7,7 @@ @code { private SfPdfViewer2 viewer; - private string DocumentPath = "wwwroot/data/form-filling-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document.pdf"; private async Task AddTextBox() { diff --git a/Form Designer/Components/Pages/ApplyFormFieldFlags.md b/Form Designer/Components/Pages/ApplyFormFieldFlags.md index c081224b..0165f149 100644 --- a/Form Designer/Components/Pages/ApplyFormFieldFlags.md +++ b/Form Designer/Components/Pages/ApplyFormFieldFlags.md @@ -11,14 +11,14 @@ private SfPdfViewer2? viewer; // Path to the PDF document to be loaded in the viewer - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; // Method triggered when the document is loaded private async Task OnDocumentLoaded() { if (viewer == null) return; - var formFields = new List + List formFields = new List { // Read-only Textbox that is not required new TextBoxField diff --git a/Form Designer/Components/Pages/CustomizeTextBox.md b/Form Designer/Components/Pages/CustomizeTextBox.md index 0ca05314..d350314d 100644 --- a/Form Designer/Components/Pages/CustomizeTextBox.md +++ b/Form Designer/Components/Pages/CustomizeTextBox.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnEditTextbox() { @@ -17,7 +17,7 @@ List fields = await viewer.GetFormFieldsAsync(); - var field = fields?.FirstOrDefault(f => f.Name == "FirstName"); + FormFieldInfo? field = fields?.FirstOrDefault(f => f.Name == "FirstName"); if (field != null) { diff --git a/Form Designer/Components/Pages/ExtractAllFormFieldValues.md b/Form Designer/Components/Pages/ExtractAllFormFieldValues.md index e3da6a6d..cd38f0fc 100644 --- a/Form Designer/Components/Pages/ExtractAllFormFieldValues.md +++ b/Form Designer/Components/Pages/ExtractAllFormFieldValues.md @@ -9,14 +9,14 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document_With_Data.pdf"; private async Task ExtractAllFieldValues() { if (viewer == null) return; - var formFields = await viewer.GetFormFieldsAsync(); + List formFields = await viewer.GetFormFieldsAsync(); - foreach (var field in formFields) + foreach (FormFieldInfo field in formFields) { if (field is CheckBoxField checkBoxField) { @@ -32,7 +32,7 @@ } else if (field is DropDownField dropDownField) { - var selectedItem = dropDownField.Items.ElementAtOrDefault(dropDownField.SelectedIndex); + ListItem? selectedItem = dropDownField.Items.ElementAtOrDefault(dropDownField.SelectedIndex); Console.WriteLine($"{field.Name}: {selectedItem?.Value}"); } else diff --git a/Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md b/Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md index 99bfd068..367ad828 100644 --- a/Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md +++ b/Form Designer/Components/Pages/ExtractFormDataAfterDocumentLoaded.md @@ -7,15 +7,15 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document_With_Data.pdf"; private async Task OnDocumentLoaded() { if (viewer == null) return; // Access form data right after the PDF loads - var formFields = await viewer.GetFormFieldsAsync(); - var emailField = formFields.FirstOrDefault(field => field is TextBoxField && field.Name == "email") as TextBoxField; + List formFields = await viewer.GetFormFieldsAsync(); + TextBoxField? emailField = formFields.FirstOrDefault(field => field is TextBoxField && field.Name == "email") as TextBoxField; string email = emailField?.Value ?? string.Empty; Console.WriteLine($"Email: {email}"); diff --git a/Form Designer/Components/Pages/FillFormFieldsProgrammatically.md b/Form Designer/Components/Pages/FillFormFieldsProgrammatically.md index d24a39e3..f71118de 100644 --- a/Form Designer/Components/Pages/FillFormFieldsProgrammatically.md +++ b/Form Designer/Components/Pages/FillFormFieldsProgrammatically.md @@ -2,7 +2,7 @@ @using Syncfusion.Blazor.SfPdfViewer @@ -23,7 +23,7 @@ return; // Find textbox safely - var textField = formFields + TextBoxField? textField = formFields .OfType() .FirstOrDefault(f => f.Name == "name") ?? formFields.OfType().FirstOrDefault(); diff --git a/Form Designer/Components/Pages/FlattenFormFields.md b/Form Designer/Components/Pages/FlattenFormFields.md index f5102170..941546b1 100644 --- a/Form Designer/Components/Pages/FlattenFormFields.md +++ b/Form Designer/Components/Pages/FlattenFormFields.md @@ -14,7 +14,7 @@ @code { private SfPdfViewer2? Viewer; - public string DocumentPath { get; set; } = "wwwroot/data/form-filling-document.pdf"; + public string DocumentPath { get; set; } = "wwwroot/data/Form_Filling_Document.pdf"; private async Task FlattenDownload() { diff --git a/Form Designer/Components/Pages/GetAllFormFields.md b/Form Designer/Components/Pages/GetAllFormFields.md index 24aec3be..1ee3c972 100644 --- a/Form Designer/Components/Pages/GetAllFormFields.md +++ b/Form Designer/Components/Pages/GetAllFormFields.md @@ -9,12 +9,12 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document_With_Data.pdf"; private async Task GetAllFormFields() { if (viewer == null) return; - var formFields = await viewer.GetFormFieldsAsync(); + List formFields = await viewer.GetFormFieldsAsync(); Console.WriteLine($"Total form fields: {formFields.Count}"); } } diff --git a/Form Designer/Components/Pages/GroupFormFields.md b/Form Designer/Components/Pages/GroupFormFields.md index 199424a4..a429f363 100644 --- a/Form Designer/Components/Pages/GroupFormFields.md +++ b/Form Designer/Components/Pages/GroupFormFields.md @@ -7,14 +7,14 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnDocumentLoaded() { if (viewer == null) return; // Create grouped form fields with the same name - var formFields = new List + List formFields = new List { // Textbox group: same name => mirrored value new TextBoxField diff --git a/Form Designer/Components/Pages/ImportExportFormFieldData.md b/Form Designer/Components/Pages/ImportExportFormFieldData.md index 02787e0e..3fb21ee6 100644 --- a/Form Designer/Components/Pages/ImportExportFormFieldData.md +++ b/Form Designer/Components/Pages/ImportExportFormFieldData.md @@ -5,7 +5,7 @@ Export Data Import Data - @@ -15,7 +15,7 @@ SfPdfViewer2 PdfViewerInstance { get; set; } // Stream to store exported form field data in FDF format - Stream FDFStream = new MemoryStream(); + MemoryStream FDFStream = new MemoryStream(); // List to store form field information List FormFields = new List(); diff --git a/Form Designer/Components/Pages/MakeFieldsReadOnly.md b/Form Designer/Components/Pages/MakeFieldsReadOnly.md index e23e5c0e..9a6e3bb6 100644 --- a/Form Designer/Components/Pages/MakeFieldsReadOnly.md +++ b/Form Designer/Components/Pages/MakeFieldsReadOnly.md @@ -11,14 +11,14 @@ private SfPdfViewer2? viewer; // Path to the PDF document to be loaded in the viewer - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; // Method triggered when the document is loaded private async Task OnDocumentLoaded() { if (viewer == null) return; - var formFields = new List + List formFields = new List { // Read-only Textbox new TextBoxField diff --git a/Form Designer/Components/Pages/MarkFieldsRequired.md b/Form Designer/Components/Pages/MarkFieldsRequired.md index 045ff747..e21e5359 100644 --- a/Form Designer/Components/Pages/MarkFieldsRequired.md +++ b/Form Designer/Components/Pages/MarkFieldsRequired.md @@ -11,14 +11,14 @@ private SfPdfViewer2? viewer; // Path to the PDF document to be loaded in the viewer - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; // Method triggered when the document is loaded private async Task OnDocumentLoaded() { if (viewer == null) return; - var formFields = new List + List formFields = new List { new TextBoxField { @@ -36,7 +36,7 @@ private void OnValidateFormFields(ValidateFormFieldsArgs args) { Dictionary unfilledFields = args.UnfilledFields; - foreach (var field in unfilledFields) + foreach (KeyValuePair field in unfilledFields) { Console.WriteLine($"Field Name: {field.Key}, Default Value: {field.Value}"); // Further processing of unfilled fields diff --git a/Form Designer/Components/Pages/MoveResizeFormFields.md b/Form Designer/Components/Pages/MoveResizeFormFields.md index 6a4cc6c5..72b69a64 100644 --- a/Form Designer/Components/Pages/MoveResizeFormFields.md +++ b/Form Designer/Components/Pages/MoveResizeFormFields.md @@ -10,14 +10,14 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnAddFormFields() { if (viewer == null) return; // Create form fields with initial bounds - var formFields = new List + List formFields = new List { new TextBoxField { @@ -48,7 +48,7 @@ List fields = await viewer.GetFormFieldsAsync(); // Find the "First Name" field - var field = fields?.FirstOrDefault(f => f.Name == "FirstName"); + FormFieldInfo? field = fields?.FirstOrDefault(f => f.Name == "FirstName"); if (field != null) { diff --git a/Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md b/Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md index 45dac987..c1ce9619 100644 --- a/Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md +++ b/Form Designer/Components/Pages/ReadCheckboxRadioButtonValues.md @@ -9,14 +9,14 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document_With_Data.pdf"; private async Task ReadCheckboxValues() { if (viewer == null) return; - var formFields = await viewer.GetFormFieldsAsync(); - var radioButtons = formFields.OfType().Where(field => field.Name == "gender").ToList(); - var checkedField = radioButtons.FirstOrDefault(field => field.IsSelected); + List formFields = await viewer.GetFormFieldsAsync(); + List radioButtons = formFields.OfType().Where(field => field.Name == "gender").ToList(); + RadioButtonField? checkedField = radioButtons.FirstOrDefault(field => field.IsSelected); string fieldName = checkedField?.Name ?? string.Empty; Console.WriteLine($"Selected radio button: {fieldName}"); } diff --git a/Form Designer/Components/Pages/ReadCustomData.md b/Form Designer/Components/Pages/ReadCustomData.md index 60bcad54..9deb5a4c 100644 --- a/Form Designer/Components/Pages/ReadCustomData.md +++ b/Form Designer/Components/Pages/ReadCustomData.md @@ -7,17 +7,17 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnDocumentLoaded() { if (viewer == null) return; // Get all form fields - var fields = await viewer.GetFormFieldsAsync(); + List fields = await viewer.GetFormFieldsAsync(); // Access custom data from each field - foreach (var field in fields) + foreach (FormFieldInfo field in fields) { Console.WriteLine($"Field: {field.Name}"); if (field.CustomData != null) diff --git a/Form Designer/Components/Pages/ReadDropdownValues.md b/Form Designer/Components/Pages/ReadDropdownValues.md index 83d432fc..eaf1f70c 100644 --- a/Form Designer/Components/Pages/ReadDropdownValues.md +++ b/Form Designer/Components/Pages/ReadDropdownValues.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document_With_Data.pdf"; private async Task ReadDropdownValues() { @@ -17,8 +17,8 @@ try { - var formFields = await viewer.GetFormFieldsAsync(); - var dropdownField = formFields?.FirstOrDefault(field => field is DropDownField && field.Name == "state") as DropDownField; + List formFields = await viewer.GetFormFieldsAsync(); + DropDownField? dropdownField = formFields?.FirstOrDefault(field => field is DropDownField && field.Name == "state") as DropDownField; if (dropdownField != null && dropdownField.Items != null && dropdownField.Items.Count > 0) { diff --git a/Form Designer/Components/Pages/ReadSignatureFieldData.md b/Form Designer/Components/Pages/ReadSignatureFieldData.md index 79d0f6cb..fcd49d76 100644 --- a/Form Designer/Components/Pages/ReadSignatureFieldData.md +++ b/Form Designer/Components/Pages/ReadSignatureFieldData.md @@ -9,13 +9,13 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document_With_Data.pdf"; private async Task ReadSignatureData() { if (viewer == null) return; - var formFields = await viewer.GetFormFieldsAsync(); - var signatureField = formFields.FirstOrDefault(field => field is SignatureField && field.Name == "signature") as SignatureField; + List formFields = await viewer.GetFormFieldsAsync(); + SignatureField? signatureField = formFields.FirstOrDefault(field => field is SignatureField && field.Name == "signature") as SignatureField; string signatureData = signatureField?.Value ?? string.Empty; Console.WriteLine($"Signature data: {signatureData}"); } diff --git a/Form Designer/Components/Pages/ReadTextFieldValues.md b/Form Designer/Components/Pages/ReadTextFieldValues.md index c689f12c..078db81e 100644 --- a/Form Designer/Components/Pages/ReadTextFieldValues.md +++ b/Form Designer/Components/Pages/ReadTextFieldValues.md @@ -9,13 +9,13 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-document.pdf"; + private string DocumentPath = "wwwroot/data/Form_Filling_Document_With_Data.pdf"; private async Task ReadTextFields() { if (viewer == null) return; - var formFields = await viewer.GetFormFieldsAsync(); - var nameField = formFields.FirstOrDefault(field => field is TextBoxField && field.Name == "name") as TextBoxField; + List formFields = await viewer.GetFormFieldsAsync(); + TextBoxField? nameField = formFields.FirstOrDefault(field => field is TextBoxField && field.Name == "name") as TextBoxField; string nameValue = nameField?.Value ?? string.Empty; Console.WriteLine($"Name field value: {nameValue}"); } diff --git a/Form Designer/Components/Pages/UpdateButton.md b/Form Designer/Components/Pages/UpdateButton.md index 763cb2b6..74f563ed 100644 --- a/Form Designer/Components/Pages/UpdateButton.md +++ b/Form Designer/Components/Pages/UpdateButton.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnEditButton() { @@ -17,7 +17,7 @@ List fields = await viewer.GetFormFieldsAsync(); - var field = fields?.FirstOrDefault(f => f.Name == "SubmitButton"); + FormFieldInfo? field = fields?.FirstOrDefault(f => f.Name == "SubmitButton"); if (field != null) { diff --git a/Form Designer/Components/Pages/UpdateCheckBox.md b/Form Designer/Components/Pages/UpdateCheckBox.md index b5cd44cd..75adc816 100644 --- a/Form Designer/Components/Pages/UpdateCheckBox.md +++ b/Form Designer/Components/Pages/UpdateCheckBox.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnEditCheckbox() { @@ -17,7 +17,7 @@ List fields = await viewer.GetFormFieldsAsync(); - var cb = fields?.FirstOrDefault(f => f.Name == "Subscribe"); + FormFieldInfo? cb = fields?.FirstOrDefault(f => f.Name == "Subscribe"); if (cb != null) { diff --git a/Form Designer/Components/Pages/UpdateCustomData.md b/Form Designer/Components/Pages/UpdateCustomData.md index 5aed7771..8f61de6f 100644 --- a/Form Designer/Components/Pages/UpdateCustomData.md +++ b/Form Designer/Components/Pages/UpdateCustomData.md @@ -10,21 +10,21 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task UpdateFirstFieldCustomData() { if (viewer == null) return; // Get all form fields - var fields = await viewer.GetFormFieldsAsync(); + List fields = await viewer.GetFormFieldsAsync(); if (fields.Count == 0) return; // Get the first field - var targetField = fields[0]; + FormFieldInfo targetField = fields[0]; // Update custom data - var updatedCustomData = new Dictionary + Dictionary updatedCustomData = new Dictionary { { "group", "profile" }, { "flags", new[] { "pii", "masked" } }, diff --git a/Form Designer/Components/Pages/UpdateDropDown.md b/Form Designer/Components/Pages/UpdateDropDown.md index 83466828..1f792953 100644 --- a/Form Designer/Components/Pages/UpdateDropDown.md +++ b/Form Designer/Components/Pages/UpdateDropDown.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/formDesigner_Document.pdf"; + private string DocumentPath = "wwwroot/data/FormDesigner_Document.pdf"; private async Task UpdateFormField() { @@ -18,7 +18,7 @@ List formFields = await viewer.GetFormFieldsAsync(); // Find only the specific dropdown by name - var dropDown = formFields?.FirstOrDefault(f => f.Name == "CountryDropdown" && f is DropDownField) as DropDownField; + DropDownField? dropDown = formFields?.FirstOrDefault(f => f.Name == "CountryDropdown" && f is DropDownField) as DropDownField; if (dropDown != null) { dropDown.Items = new List { diff --git a/Form Designer/Components/Pages/UpdateFormFieldFlags.md b/Form Designer/Components/Pages/UpdateFormFieldFlags.md index dfa8cac3..3100e1a9 100644 --- a/Form Designer/Components/Pages/UpdateFormFieldFlags.md +++ b/Form Designer/Components/Pages/UpdateFormFieldFlags.md @@ -11,7 +11,7 @@ private SfPdfViewer2? viewer; // Path to the PDF document to be loaded in the viewer - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; // Method triggered when the document is loaded private async Task OnDocumentLoaded() @@ -19,7 +19,7 @@ if (viewer == null) return; // 1) Add a sample textbox - var formFields = new List + List formFields = new List { new TextBoxField { @@ -31,8 +31,8 @@ await viewer.AddFormFieldsAsync(formFields); // 2) Retrieve and update constraint flags - var allFields = await viewer.GetFormFieldsAsync(); - var field = allFields.FirstOrDefault(f => f.Name == "Email"); + List allFields = await viewer.GetFormFieldsAsync(); + FormFieldInfo? field = allFields.FirstOrDefault(f => f.Name == "Email"); if (field is TextBoxField emailField) { diff --git a/Form Designer/Components/Pages/UpdateListBox.md b/Form Designer/Components/Pages/UpdateListBox.md index 39987bee..070881f9 100644 --- a/Form Designer/Components/Pages/UpdateListBox.md +++ b/Form Designer/Components/Pages/UpdateListBox.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/formDesigner_Document.pdf"; + private string DocumentPath = "wwwroot/data/FormDesigner_Document.pdf"; private async Task UpdateFormField() { @@ -18,7 +18,7 @@ List formFields = await viewer.GetFormFieldsAsync(); // Find and update ListBoxField - var listBox = formFields?.FirstOrDefault(f => f.Name == "InterestListBox" && f is ListBoxField) as ListBoxField; + ListBoxField? listBox = formFields?.FirstOrDefault(f => f.Name == "InterestListBox" && f is ListBoxField) as ListBoxField; if (listBox != null) { listBox.Items = new List { diff --git a/Form Designer/Components/Pages/UpdatePassword.md b/Form Designer/Components/Pages/UpdatePassword.md index 84a62d84..3c9b6cda 100644 --- a/Form Designer/Components/Pages/UpdatePassword.md +++ b/Form Designer/Components/Pages/UpdatePassword.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnEditPassword() { @@ -17,7 +17,7 @@ List fields = await viewer.GetFormFieldsAsync(); - var field = fields?.FirstOrDefault(f => f.Name == "Password"); + FormFieldInfo? field = fields?.FirstOrDefault(f => f.Name == "Password"); if (field != null) { diff --git a/Form Designer/Components/Pages/UpdateRadioButton.md b/Form Designer/Components/Pages/UpdateRadioButton.md index 76fa0c32..66134782 100644 --- a/Form Designer/Components/Pages/UpdateRadioButton.md +++ b/Form Designer/Components/Pages/UpdateRadioButton.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnEditRadio() { @@ -17,7 +17,7 @@ List fields = await viewer.GetFormFieldsAsync(); - var genderRadios = fields?.Where(f => f.Name == "Gender").ToList(); + List? genderRadios = fields?.Where(f => f.Name == "Gender").ToList(); if (genderRadios?.Count > 1) { diff --git a/Form Designer/Components/Pages/UpdateSignature.md b/Form Designer/Components/Pages/UpdateSignature.md index 78356468..2e49e4da 100644 --- a/Form Designer/Components/Pages/UpdateSignature.md +++ b/Form Designer/Components/Pages/UpdateSignature.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnEditSignature() { @@ -17,7 +17,7 @@ List fields = await viewer.GetFormFieldsAsync(); - var sig = fields?.FirstOrDefault(f => f.Name == "Sign"); + FormFieldInfo? sig = fields?.FirstOrDefault(f => f.Name == "Sign"); if (sig != null) { diff --git a/Form Designer/Components/Pages/UpdateTextBox.md b/Form Designer/Components/Pages/UpdateTextBox.md index 6e67e45b..77ae1534 100644 --- a/Form Designer/Components/Pages/UpdateTextBox.md +++ b/Form Designer/Components/Pages/UpdateTextBox.md @@ -9,7 +9,7 @@ @code { private SfPdfViewer2? viewer; - private string DocumentPath = "wwwroot/data/form-designer.pdf"; + private string DocumentPath = "wwwroot/data/Form_Designer.pdf"; private async Task OnEditTextbox() { @@ -17,7 +17,7 @@ List fields = await viewer.GetFormFieldsAsync(); - var field = fields?.FirstOrDefault(f => f.Name == "FirstName"); + FormFieldInfo? field = fields?.FirstOrDefault(f => f.Name == "FirstName"); if (field != null) { diff --git a/Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md b/Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md index 108cb785..39b32483 100644 --- a/Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md +++ b/Form Designer/Components/Pages/ValidateFormFieldsOnSubmit.md @@ -3,7 +3,7 @@ @using Syncfusion.Blazor.Buttons @@ -32,7 +32,7 @@ private void OnValidateFormFields(ValidateFormFieldsArgs args) { Dictionary unfilledFields = args.UnfilledFields; - foreach (var field in unfilledFields) + foreach (KeyValuePair field in unfilledFields) { Console.WriteLine($"Field Name: {field.Key}, Default Value: {field.Value}"); // Further processing of unfilled fields