diff --git a/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF.sln b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF.sln new file mode 100644 index 00000000..b71c6f6d --- /dev/null +++ b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35617.110 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Changing-Checkmark-and-RadioButton-Colors-in-PDF", "Changing-Checkmark-and-RadioButton-Colors-in-PDF\Changing-Checkmark-and-RadioButton-Colors-in-PDF.csproj", "{3DB23055-CE19-4219-98E7-A7292FE77EA8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3DB23055-CE19-4219-98E7-A7292FE77EA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DB23055-CE19-4219-98E7-A7292FE77EA8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DB23055-CE19-4219-98E7-A7292FE77EA8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DB23055-CE19-4219-98E7-A7292FE77EA8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {33BA272D-C49E-455A-8278-DDDE867443E1} + EndGlobalSection +EndGlobal diff --git a/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF.csproj b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF.csproj new file mode 100644 index 00000000..beaff024 --- /dev/null +++ b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF.csproj @@ -0,0 +1,27 @@ + + + + Exe + net8.0 + Changing_Checkmark_and_RadioButton_Colors_in_PDF + enable + enable + Linux + + + + + + + + + Always + + + + + + + + + diff --git a/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Data/Input.pdf b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Data/Input.pdf new file mode 100644 index 00000000..c84f0e3a Binary files /dev/null and b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Data/Input.pdf differ diff --git a/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Output/.gitkeep b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Program.cs b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Program.cs new file mode 100644 index 00000000..456b238e --- /dev/null +++ b/Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Program.cs @@ -0,0 +1,40 @@ +// See https://aka.ms/new-console-template for more information + +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using System.IO; + +FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); +// Load the PDF document +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream); +// Access the existing form fields +PdfLoadedForm form = loadedDocument.Form; +// Iterate through the fields +foreach (PdfLoadedField field in form.Fields) +{ + // Check for checkbox fields + if (field is PdfLoadedCheckBoxField checkBoxField) + { + checkBoxField.ForeColor = Color.Red; // Set desired color + } + // Check for radio button fields + else if (field is PdfLoadedRadioButtonListField radioButtonField) + { + foreach (PdfLoadedRadioButtonItem item in radioButtonField.Items) + { + item.ForeColor = Color.Blue; // Set desired color + } + } +} + +//Create file stream. +using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document to file stream. + loadedDocument.Save(outputFileStream); +} + +//Close the document. +loadedDocument.Close(true);