diff --git a/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections.sln b/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections.sln new file mode 100644 index 00000000..4fa7aa4f --- /dev/null +++ b/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections.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}") = "Header-Management-in-PDF-Sections", "Header-Management-in-PDF-Sections\Header-Management-in-PDF-Sections.csproj", "{06CEE8F2-2719-4BA0-982D-04E1F7AAEFDA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {06CEE8F2-2719-4BA0-982D-04E1F7AAEFDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06CEE8F2-2719-4BA0-982D-04E1F7AAEFDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06CEE8F2-2719-4BA0-982D-04E1F7AAEFDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06CEE8F2-2719-4BA0-982D-04E1F7AAEFDA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Header-Management-in-PDF-Sections.csproj b/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Header-Management-in-PDF-Sections.csproj new file mode 100644 index 00000000..40bfc478 --- /dev/null +++ b/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Header-Management-in-PDF-Sections.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Header_Management_in_PDF_Sections + enable + enable + + + + + + + diff --git a/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Output/gitkeep.txt b/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Program.cs b/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Program.cs new file mode 100644 index 00000000..b107ec9a --- /dev/null +++ b/Header and Footer/Header-Management-in-PDF-Sections/.NET/Header-Management-in-PDF-Sections/Program.cs @@ -0,0 +1,62 @@ +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + +namespace Header_Management_in_PDF_Sections +{ + public class Program + { + public static void Main(string[] args) + { + // Initialize the PDF document + PdfDocument document = new PdfDocument(); + + // Define the font for the header + PdfFont headerfont = new PdfStandardFont(PdfFontFamily.Helvetica, 12); + + // Create the first section with headers + PdfSection sectionWithHeaders = document.Sections.Add(); + // Apply header to this section + sectionWithHeaders.Template.Top = CreateHeaderTemplate(headerfont); + + // Add 5 pages in the first section + for (int i = 0; i < 5; i++) + { + PdfPage page = sectionWithHeaders.Pages.Add(); + DrawContentOnPage(page, $"Content for page {i + 1} in section with headers"); + } + + // Create the second section without headers + PdfSection sectionWithoutHeaders = document.Sections.Add(); + + // Add 5 pages in the second section + for (int i = 0; i < 5; i++) + { + PdfPage page = sectionWithoutHeaders.Pages.Add(); + DrawContentOnPage(page, $"Content for page {i + 6} in section without headers"); + } + + // Save the PDF document + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.Write)) + { + document.Save(outputFileStream); + } + document.Close(true); + } + + private static PdfPageTemplateElement CreateHeaderTemplate(PdfFont headerfont) + { + RectangleF rect = new RectangleF(0, 0, 500, 50); // Adjust width and height as needed + PdfPageTemplateElement header = new PdfPageTemplateElement(rect); + header.Graphics.DrawString("Header Text", headerfont, PdfBrushes.Black, new PointF(0, 0)); // Customize your header here + return header; + } + + private static void DrawContentOnPage(PdfPage page, string content) + { + PdfGraphics graphics = page.Graphics; + // You can customize the positioning and styling of your content + graphics.DrawString(content, new PdfStandardFont(PdfFontFamily.Helvetica, 10), PdfBrushes.Black, new PointF(0, 100)); + } + } +}