1+ using Syncfusion . Pdf ;
2+ using Syncfusion . Pdf . Graphics ;
3+ using Syncfusion . Drawing ;
4+
5+ class Program
6+ {
7+ static void Main ( string [ ] args )
8+ {
9+ //Create a new document.
10+ PdfDocument document = new PdfDocument ( ) ;
11+
12+ //Add a section to the document.
13+ PdfSection section = document . Sections . Add ( ) ;
14+
15+ //Set the font for the page number.
16+ PdfFont font = new PdfStandardFont ( PdfFontFamily . Helvetica , 12 ) ;
17+
18+ //Create a section page number field.
19+ PdfSectionPageNumberField sectionPageNumber = new PdfSectionPageNumberField ( ) ;
20+
21+ //Set the page number style to LowerRoman (i, ii, iii, etc.).
22+ sectionPageNumber . NumberStyle = PdfNumberStyle . LowerRoman ;
23+ sectionPageNumber . Font = font ;
24+
25+ //Add pages to the section and draw the page number field in the footer.
26+ for ( int i = 0 ; i < 3 ; i ++ )
27+ {
28+ //Add a new page to the section.
29+ PdfPage page = section . Pages . Add ( ) ;
30+
31+ //Get the page's client size to calculate the footer position.
32+ SizeF pageSize = page . GetClientSize ( ) ;
33+
34+ //Define the position for the page number in the footer (bottom-right).
35+ PointF footerPosition = new PointF ( pageSize . Width - 50 , pageSize . Height - 20 ) ;
36+
37+ //Draw the section page number at the calculated footer position.
38+ sectionPageNumber . Draw ( page . Graphics , footerPosition ) ;
39+
40+ // You can add other content to the main body of the page here.
41+ // For example, let's draw text at the top, leaving space for the footer.
42+ page . Graphics . DrawString ( "This is the main content of a page with a footer." , font , PdfBrushes . Black , new PointF ( 10 , 10 ) ) ;
43+ }
44+
45+ //Create file stream.
46+ using ( FileStream outputFileStream = new FileStream ( Path . GetFullPath ( @"Output/Output.pdf" ) , FileMode . Create , FileAccess . ReadWrite ) )
47+ {
48+ //Save the PDF document to file stream.
49+ document . Save ( outputFileStream ) ;
50+ }
51+
52+ //Close the document.
53+ document . Close ( true ) ;
54+ }
55+ }
0 commit comments