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+ }
0 commit comments