Skip to content

963561: Added sample code for checkmark and radio button colors in PDF document #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Customize_indicator_colors</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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);
}
Loading