From a4fe9616b3669e3ead57afc826ea76f869231d8e Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 10 Mar 2025 17:25:07 +0530 Subject: [PATCH 1/5] 264229 Added sample for added radio button fields in multiple PDF pages using C# --- ...ng-Radio-Buttons-to-Multiple-PDF-Pages.sln | 22 ++++++++++++ ...Radio-Buttons-to-Multiple-PDF-Pages.csproj | 15 ++++++++ .../Output/gitkeep.txt | 0 .../Program.cs | 35 +++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln create mode 100644 Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj create mode 100644 Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Output/gitkeep.txt create mode 100644 Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln new file mode 100644 index 00000000..e80e78d5 --- /dev/null +++ b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adding-Radio-Buttons-to-Multiple-PDF-Pages", "Adding-Radio-Buttons-to-Multiple-PDF-Pages\Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj", "{3B91CB77-3B67-4F35-850F-19E70AA1AEA7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj new file mode 100644 index 00000000..2b5005eb --- /dev/null +++ b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Adding_Radio_Buttons_to_Multiple_PDF_Pages + enable + enable + + + + + + + diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Output/gitkeep.txt b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs new file mode 100644 index 00000000..aae2c297 --- /dev/null +++ b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs @@ -0,0 +1,35 @@ +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + +//Create a new PDF document +PdfDocument document = new PdfDocument(); +for (int i = 1; i <= 5; i++) +{ + //Add a new page to PDF document + PdfPage page = document.Pages.Add(); + //Draw string + page.Graphics.DrawString("Radio Button Example-" + i, new PdfStandardFont(PdfFontFamily.Helvetica, 20), PdfBrushes.Black, new PointF(10, 30)); + //Create a Radio button + PdfRadioButtonListField employeesRadioList = new PdfRadioButtonListField(page, "employeesRadioList"); + //Add the radio button into form + document.Form.Fields.Add(employeesRadioList); + page.Graphics.DrawString("Option1", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(50, 70)); + //Create radio button items + PdfRadioButtonListItem radioButtonItem1 = new PdfRadioButtonListItem("Option1"); + radioButtonItem1.Bounds = new RectangleF(10, 70, 20, 20); + page.Graphics.DrawString("Option2", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(50, 100)); + PdfRadioButtonListItem radioButtonItem2 = new PdfRadioButtonListItem("Option2"); + radioButtonItem2.Bounds = new RectangleF(10, 100, 20, 20); + //Add the items to radio button group + employeesRadioList.Items.Add(radioButtonItem1); + employeesRadioList.Items.Add(radioButtonItem2); +} +// Save the PDF document to a file +using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + document.Save(outputFileStream); +} +//Close the document +document.Close(true); \ No newline at end of file From 95abdf90ef7a12c4dc51f06c962ddfd074ce73b9 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 19 Nov 2025 17:49:10 +0530 Subject: [PATCH 2/5] 264229: Added proper code sample. --- ...Radio-Buttons-to-Multiple-PDF-Pages.csproj | 2 +- .../Program.cs | 71 +++++++++++-------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj index 2b5005eb..d5d14bbd 100644 --- a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj +++ b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj @@ -3,7 +3,7 @@ Exe net8.0 - Adding_Radio_Buttons_to_Multiple_PDF_Pages + Adding-radio-buttons-to-multiple-PDF-pages enable enable diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs index aae2c297..d3ad925b 100644 --- a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs +++ b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs @@ -1,35 +1,44 @@ -using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Interactive; -using Syncfusion.Pdf; using Syncfusion.Drawing; -//Create a new PDF document -PdfDocument document = new PdfDocument(); -for (int i = 1; i <= 5; i++) +// Create a new PDF document +using (PdfDocument document = new PdfDocument()) { - //Add a new page to PDF document - PdfPage page = document.Pages.Add(); - //Draw string - page.Graphics.DrawString("Radio Button Example-" + i, new PdfStandardFont(PdfFontFamily.Helvetica, 20), PdfBrushes.Black, new PointF(10, 30)); - //Create a Radio button - PdfRadioButtonListField employeesRadioList = new PdfRadioButtonListField(page, "employeesRadioList"); - //Add the radio button into form - document.Form.Fields.Add(employeesRadioList); - page.Graphics.DrawString("Option1", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(50, 70)); - //Create radio button items - PdfRadioButtonListItem radioButtonItem1 = new PdfRadioButtonListItem("Option1"); - radioButtonItem1.Bounds = new RectangleF(10, 70, 20, 20); - page.Graphics.DrawString("Option2", new PdfStandardFont(PdfFontFamily.Helvetica, 12), PdfBrushes.Black, new PointF(50, 100)); - PdfRadioButtonListItem radioButtonItem2 = new PdfRadioButtonListItem("Option2"); - radioButtonItem2.Bounds = new RectangleF(10, 100, 20, 20); - //Add the items to radio button group - employeesRadioList.Items.Add(radioButtonItem1); - employeesRadioList.Items.Add(radioButtonItem2); -} -// Save the PDF document to a file -using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) -{ - document.Save(outputFileStream); -} -//Close the document -document.Close(true); \ No newline at end of file + // Loop through multiple pages + for (int i = 1; i <= 5; i++) + { + // Add a new page to the PDF document + PdfPage page = document.Pages.Add(); + // Draw header text + page.Graphics.DrawString($"Radio Button Example - {i}", + new PdfStandardFont(PdfFontFamily.Helvetica, 20), + PdfBrushes.Black, new PointF(10, 30)); + // Create a Radio Button List Field + PdfRadioButtonListField employeesRadioList = new PdfRadioButtonListField(page, $"employeesRadioList_{i}") + { + AllowUnisonSelection = false // Each button acts independently + }; + // Add the radio button field to the form + document.Form.Fields.Add(employeesRadioList); + // Draw option labels + page.Graphics.DrawString("Option 1", new PdfStandardFont(PdfFontFamily.Helvetica, 12), + PdfBrushes.Black, new PointF(50, 70)); + page.Graphics.DrawString("Option 2", new PdfStandardFont(PdfFontFamily.Helvetica, 12), + PdfBrushes.Black, new PointF(50, 100)); + // Create radio button items with positions + PdfRadioButtonListItem radioButtonItem1 = new PdfRadioButtonListItem("Option1") + { + Bounds = new RectangleF(10, 70, 20, 20) + }; + PdfRadioButtonListItem radioButtonItem2 = new PdfRadioButtonListItem("Option2") + { + Bounds = new RectangleF(10, 100, 20, 20) + }; + // Add items to the radio button group + employeesRadioList.Items.Add(radioButtonItem1); + employeesRadioList.Items.Add(radioButtonItem2); + } + document.Save(Path.GetFullPath(@"Output/Output.pdf")); +} \ No newline at end of file From 27d3e2aaef0cbcd40c3b906a8b76e53ef5221059 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 19 Nov 2025 18:18:05 +0530 Subject: [PATCH 3/5] 264229: Added proper details. --- .../Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj index d5d14bbd..e3d44d0b 100644 --- a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj +++ b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj @@ -3,7 +3,7 @@ Exe net8.0 - Adding-radio-buttons-to-multiple-PDF-pages + Adding-Radio-Buttons-to-Multiple-PDF-Pages enable enable From 513348f78bb8b39aefcf128148d34e114ad2cca2 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 29 Dec 2025 15:56:55 +0530 Subject: [PATCH 4/5] 264229: Added proper code example. --- ...ng-Radio-Buttons-to-Multiple-PDF-Pages.sln | 22 -------- .../Program.cs | 44 --------------- ...DF-Radio-Button-Group-Synchronization.sln" | 25 +++++++++ ...Radio-Button-Group-Synchronization.csproj" | 2 +- .../Output/gitkeep.txt" | 0 .../Program.cs" | 56 +++++++++++++++++++ 6 files changed, 82 insertions(+), 67 deletions(-) delete mode 100644 Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln delete mode 100644 Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs create mode 100644 "Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.sln" rename Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj => "Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.csproj" (80%) rename Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Output/gitkeep.txt => "Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Output/gitkeep.txt" (100%) create mode 100644 "Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln deleted file mode 100644 index e80e78d5..00000000 --- a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.12.35707.178 d17.12 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adding-Radio-Buttons-to-Multiple-PDF-Pages", "Adding-Radio-Buttons-to-Multiple-PDF-Pages\Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj", "{3B91CB77-3B67-4F35-850F-19E70AA1AEA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B91CB77-3B67-4F35-850F-19E70AA1AEA7}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs b/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs deleted file mode 100644 index d3ad925b..00000000 --- a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Program.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Syncfusion.Pdf; -using Syncfusion.Pdf.Graphics; -using Syncfusion.Pdf.Interactive; -using Syncfusion.Drawing; - -// Create a new PDF document -using (PdfDocument document = new PdfDocument()) -{ - // Loop through multiple pages - for (int i = 1; i <= 5; i++) - { - // Add a new page to the PDF document - PdfPage page = document.Pages.Add(); - // Draw header text - page.Graphics.DrawString($"Radio Button Example - {i}", - new PdfStandardFont(PdfFontFamily.Helvetica, 20), - PdfBrushes.Black, new PointF(10, 30)); - // Create a Radio Button List Field - PdfRadioButtonListField employeesRadioList = new PdfRadioButtonListField(page, $"employeesRadioList_{i}") - { - AllowUnisonSelection = false // Each button acts independently - }; - // Add the radio button field to the form - document.Form.Fields.Add(employeesRadioList); - // Draw option labels - page.Graphics.DrawString("Option 1", new PdfStandardFont(PdfFontFamily.Helvetica, 12), - PdfBrushes.Black, new PointF(50, 70)); - page.Graphics.DrawString("Option 2", new PdfStandardFont(PdfFontFamily.Helvetica, 12), - PdfBrushes.Black, new PointF(50, 100)); - // Create radio button items with positions - PdfRadioButtonListItem radioButtonItem1 = new PdfRadioButtonListItem("Option1") - { - Bounds = new RectangleF(10, 70, 20, 20) - }; - PdfRadioButtonListItem radioButtonItem2 = new PdfRadioButtonListItem("Option2") - { - Bounds = new RectangleF(10, 100, 20, 20) - }; - // Add items to the radio button group - employeesRadioList.Items.Add(radioButtonItem1); - employeesRadioList.Items.Add(radioButtonItem2); - } - document.Save(Path.GetFullPath(@"Output/Output.pdf")); -} \ No newline at end of file diff --git "a/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.sln" "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.sln" new file mode 100644 index 00000000..b1d8c773 --- /dev/null +++ "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.sln" @@ -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}") = "Multi‑Page-PDF-Radio-Button-Group-Synchronization", "Multi‑Page-PDF-Radio-Button-Group-Synchronization\Multi‑Page-PDF-Radio-Button-Group-Synchronization.csproj", "{268276E6-E841-4FDC-BA43-80B6A95921CE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {268276E6-E841-4FDC-BA43-80B6A95921CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {268276E6-E841-4FDC-BA43-80B6A95921CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {268276E6-E841-4FDC-BA43-80B6A95921CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {268276E6-E841-4FDC-BA43-80B6A95921CE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {05CFF1BA-A827-4272-A101-1018EB8FC017} + EndGlobalSection +EndGlobal diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.csproj" similarity index 80% rename from Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj rename to "Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.csproj" index e3d44d0b..960669a8 100644 --- a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Adding-Radio-Buttons-to-Multiple-PDF-Pages.csproj +++ "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization.csproj" @@ -3,7 +3,7 @@ Exe net8.0 - Adding-Radio-Buttons-to-Multiple-PDF-Pages + Multi_Page_PDF_Radio_Button_Group_Synchronization enable enable diff --git a/Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Output/gitkeep.txt "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Output/gitkeep.txt" similarity index 100% rename from Forms/Adding-Radio-Buttons-to-Multiple-PDF-Pages/.NET/Adding-Radio-Buttons-to-Multiple-PDF-Pages/Output/gitkeep.txt rename to "Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Output/gitkeep.txt" diff --git "a/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" new file mode 100644 index 00000000..fedb23aa --- /dev/null +++ "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" @@ -0,0 +1,56 @@ +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Interactive; + +// Create a new PDF document +using (PdfDocument document = new PdfDocument()) +{ + // Add pages (adjust count as needed) + PdfPage[] pages = { document.Pages.Add(), document.Pages.Add() }; + // Access the document form + PdfForm form = document.Form; + // Disable auto field naming (we will name fields explicitly) + form.FieldAutoNaming = false; + // Common font for labels + PdfFont labelFont = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Regular); + // Shared settings + string groupName = "EmployeesRadioGroup"; // same group name across pages + string[] exportValues = { "rb1", "rb2", "rb3" }; // consistent export values + float[] startYs = { 200f, 300f }; // starting Y per page + float labelOffsetX = 10f; // label X offset from radio button + float labelOffsetY = -2f; // label Y tweak + for (int p = 0; p < pages.Length; p++) + { + PdfPage page = pages[p]; + // Create a radio button field for this page (same group name) + PdfRadioButtonListField radioField = new PdfRadioButtonListField(page, groupName) + { + // Keep selection behavior consistent + AllowUnisonSelection = true + }; + // Add items and draw labels via loop + for (int i = 0; i < exportValues.Length; i++) + { + // Intialized bounds value + RectangleF bounds = new RectangleF(100f, startYs[p] + (i * 40f), 20f, 20f); + // Create item with consistent export value + PdfRadioButtonListItem item = new PdfRadioButtonListItem(page, exportValues[i]) + { + Bounds = bounds + }; + radioField.Items.Add(item); + // Draw label near the radio button + page.Graphics.DrawString($"Radio Button {i + 1}", labelFont, PdfBrushes.Black, bounds.Right + labelOffsetX, bounds.Y + labelOffsetY); + } + // Set default selection on the first page + if (p == 0 && exportValues.Length > 0) + { + radioField.SelectedValue = exportValues[0]; + } + // Add the field to the form + form.Fields.Add(radioField); + } + // Save the PDF document + document.Save(Path.GetFullPath(@"Output/Output.pdf")); +} \ No newline at end of file From 01ee8866e014b9a440d472ed52bcbea60ad42ebb Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Wed, 31 Dec 2025 12:26:24 +0530 Subject: [PATCH 5/5] 264229: Resolved the given feedback. --- .../Program.cs" | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git "a/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" index fedb23aa..c6d96465 100644 --- "a/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" +++ "b/Forms/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/.NET/Multi\342\200\221Page-PDF-Radio-Button-Group-Synchronization/Program.cs" @@ -6,51 +6,48 @@ // Create a new PDF document using (PdfDocument document = new PdfDocument()) { - // Add pages (adjust count as needed) - PdfPage[] pages = { document.Pages.Add(), document.Pages.Add() }; - // Access the document form + // Create two pages + PdfPage page1 = document.Pages.Add(); + PdfPage page2 = document.Pages.Add(); + // Access the form PdfForm form = document.Form; - // Disable auto field naming (we will name fields explicitly) form.FieldAutoNaming = false; - // Common font for labels + // Label font PdfFont labelFont = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Regular); - // Shared settings - string groupName = "EmployeesRadioGroup"; // same group name across pages - string[] exportValues = { "rb1", "rb2", "rb3" }; // consistent export values - float[] startYs = { 200f, 300f }; // starting Y per page - float labelOffsetX = 10f; // label X offset from radio button - float labelOffsetY = -2f; // label Y tweak - for (int p = 0; p < pages.Length; p++) + // Group name + string groupName = "EmployeesRadioGroup"; + float labelOffsetX = 10f; + float labelOffsetY = -2f; + // Create ONE radio button list field (anchor it on the first page; items can be on any page) + PdfRadioButtonListField radioField = new PdfRadioButtonListField(page1, groupName) { - PdfPage page = pages[p]; - // Create a radio button field for this page (same group name) - PdfRadioButtonListField radioField = new PdfRadioButtonListField(page, groupName) + // Keep standard radio behavior: only one selection in the group + AllowUnisonSelection = false + }; + // Define the 4 radio items: 2 on page 1, 2 on page 2 + var items = new (PdfPage page, string export, RectangleF bounds, string label)[] + { + (page1, "rb1", new RectangleF(100f, 200f, 20f, 20f), "Radio Button 1"), + (page1, "rb2", new RectangleF(100f, 240f, 20f, 20f), "Radio Button 2"), + (page2, "rb3", new RectangleF(100f, 200f, 20f, 20f), "Radio Button 3"), + (page2, "rb4", new RectangleF(100f, 240f, 20f, 20f), "Radio Button 4"), + }; + // Add items to the single radio field and draw their labels + foreach (var (page, export, bounds, label) in items) + { + PdfRadioButtonListItem item = new PdfRadioButtonListItem(page, export) { - // Keep selection behavior consistent - AllowUnisonSelection = true + Bounds = bounds }; - // Add items and draw labels via loop - for (int i = 0; i < exportValues.Length; i++) - { - // Intialized bounds value - RectangleF bounds = new RectangleF(100f, startYs[p] + (i * 40f), 20f, 20f); - // Create item with consistent export value - PdfRadioButtonListItem item = new PdfRadioButtonListItem(page, exportValues[i]) - { - Bounds = bounds - }; - radioField.Items.Add(item); - // Draw label near the radio button - page.Graphics.DrawString($"Radio Button {i + 1}", labelFont, PdfBrushes.Black, bounds.Right + labelOffsetX, bounds.Y + labelOffsetY); - } - // Set default selection on the first page - if (p == 0 && exportValues.Length > 0) - { - radioField.SelectedValue = exportValues[0]; - } - // Add the field to the form - form.Fields.Add(radioField); + radioField.Items.Add(item); + // Label beside the radio button + page.Graphics.DrawString(label, labelFont, PdfBrushes.Black, + bounds.Right + labelOffsetX, bounds.Y + labelOffsetY); } + // Set default selection + radioField.SelectedValue = "rb4"; + // Add the single field to the form + form.Fields.Add(radioField); // Save the PDF document document.Save(Path.GetFullPath(@"Output/Output.pdf")); } \ No newline at end of file