Skip to content

Task 926561- Changing the checkbox and radiobutton color in the PDF #172

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Changing_Checkmark_and_RadioButton_Colors_in_PDF</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<None Remove="Data\Input.pdf" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Data\Input.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Syncfusion.Pdf.NET" Version="*" />
</ItemGroup>

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