From 61362741f8b5c11664edc03b5849c1026481a50b Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 11 Aug 2025 12:26:02 +0530 Subject: [PATCH 1/4] 923636: Added code sample for set section page numbers with custom styles in PDFs --- ...Add-roman-page-numbers-to-PDF-sections.sln | 25 +++++++++++++++++ ...-roman-page-numbers-to-PDF-sections.csproj | 15 ++++++++++ .../Output/gitkeep.txt | 0 .../Program.cs | 28 +++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln create mode 100644 Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj create mode 100644 Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Output/gitkeep.txt create mode 100644 Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Program.cs diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln b/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln new file mode 100644 index 00000000..183f7d91 --- /dev/null +++ b/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36221.1 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-roman-page-numbers-to-PDF-sections", "Add-roman-page-numbers-to-PDF-sections\Add-roman-page-numbers-to-PDF-sections.csproj", "{73050DDC-B7A3-48AC-AAF9-72B3710424DC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BD540509-74DF-4C8F-9D94-6D807B315F6C} + EndGlobalSection +EndGlobal diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj b/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj new file mode 100644 index 00000000..f64c80d1 --- /dev/null +++ b/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Add_roman_page_numbers_to_PDF_sections + enable + enable + + + + + + + diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Output/gitkeep.txt b/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Program.cs b/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Program.cs new file mode 100644 index 00000000..d8c8ce98 --- /dev/null +++ b/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Program.cs @@ -0,0 +1,28 @@ +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; + +//Create a new document. +PdfDocument document = new PdfDocument(); +//Add the section. +PdfSection section = document.Sections.Add(); +//Set the font. +PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); +//Create section page number field. +PdfSectionPageNumberField sectionPageNumber = new PdfSectionPageNumberField(); +sectionPageNumber.NumberStyle = PdfNumberStyle.LowerRoman; +sectionPageNumber.Font = font; +//Draw the sectionPageNumber in section. +for (int i = 0; i < 3; i++) +{ + PdfPage page = section.Pages.Add(); + sectionPageNumber.Draw(page.Graphics); + page.Graphics.DrawString("This code is a practical example of how to automatically add Roman numeral page numbers", font, PdfBrushes.Black, new Syncfusion.Drawing.PointF(10, 0)); +} +//Create file stream. +using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) +{ + //Save the PDF document to file stream. + document.Save(outputFileStream); +} +//Close the document. +document.Close(true); \ No newline at end of file From c92caf4deb358478f8b9ce9773b367e23384f334 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 11 Aug 2025 14:10:59 +0530 Subject: [PATCH 2/4] 923636: Resolved the given feedback. --- .../.NET/Setting-Section-Page-Numbers-With-Custom-Styles.sln} | 2 +- .../Output/gitkeep.txt | 0 .../Setting-Section-Page-Numbers-With-Custom-Styles}/Program.cs | 0 .../Setting-Section-Page-Numbers-With-Custom-Styles.csproj} | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename Pages/{Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln => Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles.sln} (79%) rename Pages/{Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections => Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles}/Output/gitkeep.txt (100%) rename Pages/{Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections => Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles}/Program.cs (100%) rename Pages/{Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj => Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Setting-Section-Page-Numbers-With-Custom-Styles.csproj} (80%) diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles.sln similarity index 79% rename from Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln rename to Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles.sln index 183f7d91..9a9a78b7 100644 --- a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections.sln +++ b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.14.36221.1 d17.14 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-roman-page-numbers-to-PDF-sections", "Add-roman-page-numbers-to-PDF-sections\Add-roman-page-numbers-to-PDF-sections.csproj", "{73050DDC-B7A3-48AC-AAF9-72B3710424DC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Setting-Section-Page-Numbers-With-Custom-Styles", "Setting-Section-Page-Numbers-With-Custom-Styles\Setting-Section-Page-Numbers-With-Custom-Styles.csproj", "{73050DDC-B7A3-48AC-AAF9-72B3710424DC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Output/gitkeep.txt b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Output/gitkeep.txt similarity index 100% rename from Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Output/gitkeep.txt rename to Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Output/gitkeep.txt diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Program.cs b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs similarity index 100% rename from Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Program.cs rename to Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs diff --git a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Setting-Section-Page-Numbers-With-Custom-Styles.csproj similarity index 80% rename from Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj rename to Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Setting-Section-Page-Numbers-With-Custom-Styles.csproj index f64c80d1..16619ce3 100644 --- a/Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Add-roman-page-numbers-to-PDF-sections.csproj +++ b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Setting-Section-Page-Numbers-With-Custom-Styles.csproj @@ -3,7 +3,7 @@ Exe net8.0 - Add_roman_page_numbers_to_PDF_sections + Setting-Section-Page-Numbers-With-Custom-Styles enable enable From ffa32bb6f21fc81c155ced9322ee40ef056e6399 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Mon, 11 Aug 2025 14:13:38 +0530 Subject: [PATCH 3/4] 923636: Resolved the given feedback --- .../Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs index d8c8ce98..42781dc4 100644 --- a/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs +++ b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs @@ -9,6 +9,7 @@ PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); //Create section page number field. PdfSectionPageNumberField sectionPageNumber = new PdfSectionPageNumberField(); +//Set the page number style as LowerRoman sectionPageNumber.NumberStyle = PdfNumberStyle.LowerRoman; sectionPageNumber.Font = font; //Draw the sectionPageNumber in section. From 2e17ef33383c15decb3f0fcbca8bc0c0a51345b6 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Tue, 12 Aug 2025 11:17:13 +0530 Subject: [PATCH 4/4] 923636: Resolved the given feedback. --- .../Program.cs | 76 +++++++++++++------ 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs index 42781dc4..9126dbb6 100644 --- a/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs +++ b/Pages/Setting-Section-Page-Numbers-With-Custom-Styles/.NET/Setting-Section-Page-Numbers-With-Custom-Styles/Program.cs @@ -1,29 +1,55 @@ using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; +using Syncfusion.Drawing; -//Create a new document. -PdfDocument document = new PdfDocument(); -//Add the section. -PdfSection section = document.Sections.Add(); -//Set the font. -PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); -//Create section page number field. -PdfSectionPageNumberField sectionPageNumber = new PdfSectionPageNumberField(); -//Set the page number style as LowerRoman -sectionPageNumber.NumberStyle = PdfNumberStyle.LowerRoman; -sectionPageNumber.Font = font; -//Draw the sectionPageNumber in section. -for (int i = 0; i < 3; i++) +class Program { - PdfPage page = section.Pages.Add(); - sectionPageNumber.Draw(page.Graphics); - page.Graphics.DrawString("This code is a practical example of how to automatically add Roman numeral page numbers", font, PdfBrushes.Black, new Syncfusion.Drawing.PointF(10, 0)); -} -//Create file stream. -using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) -{ - //Save the PDF document to file stream. - document.Save(outputFileStream); -} -//Close the document. -document.Close(true); \ No newline at end of file + static void Main(string[] args) + { + //Create a new document. + PdfDocument document = new PdfDocument(); + + //Add a section to the document. + PdfSection section = document.Sections.Add(); + + //Set the font for the page number. + PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12); + + //Create a section page number field. + PdfSectionPageNumberField sectionPageNumber = new PdfSectionPageNumberField(); + + //Set the page number style to LowerRoman (i, ii, iii, etc.). + sectionPageNumber.NumberStyle = PdfNumberStyle.LowerRoman; + sectionPageNumber.Font = font; + + //Add pages to the section and draw the page number field in the footer. + for (int i = 0; i < 3; i++) + { + //Add a new page to the section. + PdfPage page = section.Pages.Add(); + + //Get the page's client size to calculate the footer position. + SizeF pageSize = page.GetClientSize(); + + //Define the position for the page number in the footer (bottom-right). + PointF footerPosition = new PointF(pageSize.Width - 50, pageSize.Height - 20); + + //Draw the section page number at the calculated footer position. + sectionPageNumber.Draw(page.Graphics, footerPosition); + + // You can add other content to the main body of the page here. + // For example, let's draw text at the top, leaving space for the footer. + page.Graphics.DrawString("This is the main content of a page with a footer.", font, PdfBrushes.Black, new PointF(10, 10)); + } + + //Create file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the PDF document to file stream. + document.Save(outputFileStream); + } + + //Close the document. + document.Close(true); + } +} \ No newline at end of file