Skip to content

Commit 87853a9

Browse files
committed
994136: Added proper code example for radio button behavior with AllowUnisonSelection enabled and disabled in PDF forms.
1 parent 06d309d commit 87853a9

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-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.14.36616.10 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
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}"
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+
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{1390DDC1-ACEC-4A88-83C4-CDAD5995870F}.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 = {00C8D2AA-C3E6-46E2-9751-A5F08C69CD2F}
24+
EndGlobalSection
25+
EndGlobal

Forms/Radio-button-behavior-in-PDF-forms-with-AllowUnisonSelection/.NET/Radio-button-behavior-in-PDF-forms-with-AllowUnisonSelection/Output/gitkeep.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using Syncfusion.Drawing;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Graphics;
4+
using Syncfusion.Pdf.Interactive;
5+
6+
//Create a PDF document
7+
using (PdfDocument document = new PdfDocument())
8+
{
9+
//Page 1 - AllowUnisonSelection DISABLED(Independent behavior)
10+
PdfPage page1 = document.Pages.Add();
11+
page1.Graphics.DrawString("Independent Radio Buttons",
12+
new PdfStandardFont(PdfFontFamily.Helvetica, 16),
13+
PdfBrushes.Black, new PointF(10, 20));
14+
15+
PdfRadioButtonListField independentGroup = new PdfRadioButtonListField(page1, "IndependentGroup")
16+
{
17+
// Each button acts independently
18+
AllowUnisonSelection = false
19+
};
20+
PdfRadioButtonListItem item1 = new PdfRadioButtonListItem("OptionA")
21+
{
22+
Bounds = new RectangleF(10, 60, 20, 20)
23+
};
24+
// Same label but independent
25+
PdfRadioButtonListItem item2 = new PdfRadioButtonListItem("OptionA")
26+
{
27+
Bounds = new RectangleF(10, 100, 20, 20)
28+
};
29+
independentGroup.Items.Add(item1);
30+
independentGroup.Items.Add(item2);
31+
document.Form.Fields.Add(independentGroup);
32+
page1.Graphics.DrawString("Option A (1)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
33+
PdfBrushes.Black, new PointF(40, 60));
34+
page1.Graphics.DrawString("Option A (2)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
35+
PdfBrushes.Black, new PointF(40, 100));
36+
//Page 2 - AllowUnisonSelection ENABLED(Unified behavior)
37+
PdfPage page2 = document.Pages.Add();
38+
page2.Graphics.DrawString("Unified Radio Buttons",
39+
new PdfStandardFont(PdfFontFamily.Helvetica, 16),
40+
PdfBrushes.Black, new PointF(10, 20));
41+
PdfRadioButtonListField unifiedGroup = new PdfRadioButtonListField(page2, "UnifiedGroup")
42+
{
43+
// Buttons share selection state
44+
AllowUnisonSelection = true
45+
};
46+
PdfRadioButtonListItem item3 = new PdfRadioButtonListItem("OptionB")
47+
{
48+
Bounds = new RectangleF(10, 60, 20, 20)
49+
};
50+
// Same label, unified selection
51+
PdfRadioButtonListItem item4 = new PdfRadioButtonListItem("OptionB")
52+
{
53+
Bounds = new RectangleF(10, 100, 20, 20)
54+
};
55+
unifiedGroup.Items.Add(item3);
56+
unifiedGroup.Items.Add(item4);
57+
document.Form.Fields.Add(unifiedGroup);
58+
page2.Graphics.DrawString("Option B (1)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
59+
PdfBrushes.Black, new PointF(40, 60));
60+
page2.Graphics.DrawString("Option B (2)", new PdfStandardFont(PdfFontFamily.Helvetica, 12),
61+
PdfBrushes.Black, new PointF(40, 100));
62+
//Save the document
63+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Radio_button_behavior_in_PDF_forms_with_AllowUnisonSelection</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)