Skip to content

Commit 71ca400

Browse files
committed
Added example solution
1 parent 38cd440 commit 71ca400

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35617.110 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
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}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{3DB23055-CE19-4219-98E7-A7292FE77EA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{3DB23055-CE19-4219-98E7-A7292FE77EA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{3DB23055-CE19-4219-98E7-A7292FE77EA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{3DB23055-CE19-4219-98E7-A7292FE77EA8}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {33BA272D-C49E-455A-8278-DDDE867443E1}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Changing_Checkmark_and_RadioButton_Colors_in_PDF</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<None Remove="Data\Input.pdf" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<EmbeddedResource Include="Data\Input.pdf">
18+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19+
</EmbeddedResource>
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
24+
<PackageReference Include="Syncfusion.Pdf.NET" Version="*" />
25+
</ItemGroup>
26+
27+
</Project>

Forms/Changing-checkmark-and-radiobutton-colors-in-PDF/Changing-checkmark-and-radiobutton-colors-in-PDF/Output/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// See https://aka.ms/new-console-template for more information
2+
3+
using Syncfusion.Drawing;
4+
using Syncfusion.Pdf;
5+
using Syncfusion.Pdf.Interactive;
6+
using Syncfusion.Pdf.Parsing;
7+
using System.IO;
8+
9+
FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read);
10+
// Load the PDF document
11+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream);
12+
// Access the existing form fields
13+
PdfLoadedForm form = loadedDocument.Form;
14+
// Iterate through the fields
15+
foreach (PdfLoadedField field in form.Fields)
16+
{
17+
// Check for checkbox fields
18+
if (field is PdfLoadedCheckBoxField checkBoxField)
19+
{
20+
checkBoxField.ForeColor = Color.Red; // Set desired color
21+
}
22+
// Check for radio button fields
23+
else if (field is PdfLoadedRadioButtonListField radioButtonField)
24+
{
25+
foreach (PdfLoadedRadioButtonItem item in radioButtonField.Items)
26+
{
27+
item.ForeColor = Color.Blue; // Set desired color
28+
}
29+
}
30+
}
31+
32+
//Create file stream.
33+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
34+
{
35+
//Save the PDF document to file stream.
36+
loadedDocument.Save(outputFileStream);
37+
}
38+
39+
//Close the document.
40+
loadedDocument.Close(true);

0 commit comments

Comments
 (0)