diff --git a/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors.sln b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors.sln new file mode 100644 index 00000000..70814889 --- /dev/null +++ b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36221.1 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Customize-indicator-colors", "Customize-indicator-colors\Customize-indicator-colors.csproj", "{D5A2EFE1-DF64-41CA-9A25-A1A2EECA37EA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D5A2EFE1-DF64-41CA-9A25-A1A2EECA37EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5A2EFE1-DF64-41CA-9A25-A1A2EECA37EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5A2EFE1-DF64-41CA-9A25-A1A2EECA37EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5A2EFE1-DF64-41CA-9A25-A1A2EECA37EA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {89B8EE92-DFEA-4816-A09F-0612E45354F5} + EndGlobalSection +EndGlobal diff --git a/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Customize-indicator-colors.csproj b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Customize-indicator-colors.csproj new file mode 100644 index 00000000..df69af3a --- /dev/null +++ b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Customize-indicator-colors.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Customize_indicator_colors + enable + enable + + + + + + + diff --git a/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Data/Input.pdf b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Data/Input.pdf new file mode 100644 index 00000000..479bc96f Binary files /dev/null and b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Data/Input.pdf differ diff --git a/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Output/gitkeep.txt b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Program.cs b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Program.cs new file mode 100644 index 00000000..0bb0f553 --- /dev/null +++ b/Forms/Customize-indicator-colors/.NET/Customize-indicator-colors/Program.cs @@ -0,0 +1,41 @@ +using Syncfusion.Drawing; +using Syncfusion.Pdf.Parsing; + +// Open the input PDF file stream. +using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read)) +{ + // Load the PDF document from the input stream. + PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream); + + // Access the existing form fields in the PDF. + PdfLoadedForm form = loadedDocument.Form; + + // Iterate through all form fields to find checkboxes and radio button lists. + foreach (PdfLoadedField field in form.Fields) + { + // If the field is a checkbox, change its checkmark color using ForeColor. + if (field is PdfLoadedCheckBoxField checkBoxField) + { + checkBoxField.ForeColor = Color.Red; // Set desired checkbox color. + } + // If the field is a radio button list, change each item's dot color. + else if (field is PdfLoadedRadioButtonListField radioButtonField) + { + foreach (PdfLoadedRadioButtonItem item in radioButtonField.Items) + { + item.ForeColor = Color.Blue; // Set desired radio button color. + } + } + } + // Disable the default appearance to allow custom rendering of form fields. + form.SetDefaultAppearance(false); + // Create the output file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + // Save the modified PDF document to the new file stream. + loadedDocument.Save(outputFileStream); + } + + // Close the PDF document. + loadedDocument.Close(true); +} \ No newline at end of file