Skip to content
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.14.36616.10 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Radio-button-behavior-in-PDF-forms-with-AllowUnisonSelection", "Radio-button-behavior-in-PDF-forms-with-AllowUnisonSelection\Radio-button-behavior-in-PDF-forms-with-AllowUnisonSelection.csproj", "{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {00C8D2AA-C3E6-46E2-9751-A5F08C69CD2F}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Syncfusion.Drawing;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Interactive;

//Create a PDF document
using (PdfDocument document = new PdfDocument())
{
//Page 1 - AllowUnisonSelection DISABLED(Independent behavior)
PdfPage page1 = document.Pages.Add();
page1.Graphics.DrawString("Independent Radio Buttons",
new PdfStandardFont(PdfFontFamily.Helvetica, 16),
PdfBrushes.Black, new PointF(10, 20));

PdfRadioButtonListField independentGroup = new PdfRadioButtonListField(page1, "IndependentGroup")
{
// Each button acts independently
AllowUnisonSelection = false
};
PdfRadioButtonListItem item1 = new PdfRadioButtonListItem("OptionA")
{
Bounds = new RectangleF(10, 60, 20, 20)
};
// Same label but independent
PdfRadioButtonListItem item2 = new PdfRadioButtonListItem("OptionA")
{
Bounds = new RectangleF(10, 100, 20, 20)
};
independentGroup.Items.Add(item1);
independentGroup.Items.Add(item2);
document.Form.Fields.Add(independentGroup);
page1.Graphics.DrawString("Option A (1)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
PdfBrushes.Black, new PointF(40, 60));
page1.Graphics.DrawString("Option A (2)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
PdfBrushes.Black, new PointF(40, 100));
//Page 2 - AllowUnisonSelection ENABLED(Unified behavior)
PdfPage page2 = document.Pages.Add();
page2.Graphics.DrawString("Unified Radio Buttons",
new PdfStandardFont(PdfFontFamily.Helvetica, 16),
PdfBrushes.Black, new PointF(10, 20));
PdfRadioButtonListField unifiedGroup = new PdfRadioButtonListField(page2, "UnifiedGroup")
{
// Buttons share selection state
AllowUnisonSelection = true
};
PdfRadioButtonListItem item3 = new PdfRadioButtonListItem("OptionB")
{
Bounds = new RectangleF(10, 60, 20, 20)
};
// Same label, unified selection
PdfRadioButtonListItem item4 = new PdfRadioButtonListItem("OptionB")
{
Bounds = new RectangleF(10, 100, 20, 20)
};
unifiedGroup.Items.Add(item3);
unifiedGroup.Items.Add(item4);
document.Form.Fields.Add(unifiedGroup);
page2.Graphics.DrawString("Option B (1)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
PdfBrushes.Black, new PointF(40, 60));
page2.Graphics.DrawString("Option B (2)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
PdfBrushes.Black, new PointF(40, 100));
//Save the document
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
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>Radio_button_behavior_in_PDF_forms_with_AllowUnisonSelection</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Loading