diff --git a/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards.sln b/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards.sln new file mode 100644 index 00000000..66c0d526 --- /dev/null +++ b/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards.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}") = "Changing-Margins-from-the-Second-Page-onwards", "Changing-Margins-from-the-Second-Page-onwards\Changing-Margins-from-the-Second-Page-onwards.csproj", "{646D9954-C91D-4ACB-A104-9C9331EE1845}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {646D9954-C91D-4ACB-A104-9C9331EE1845}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {646D9954-C91D-4ACB-A104-9C9331EE1845}.Debug|Any CPU.Build.0 = Debug|Any CPU + {646D9954-C91D-4ACB-A104-9C9331EE1845}.Release|Any CPU.ActiveCfg = Release|Any CPU + {646D9954-C91D-4ACB-A104-9C9331EE1845}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards/Changing-Margins-from-the-Second-Page-onwards.csproj b/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards/Changing-Margins-from-the-Second-Page-onwards.csproj new file mode 100644 index 00000000..ea1d2207 --- /dev/null +++ b/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards/Changing-Margins-from-the-Second-Page-onwards.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Changing_Margins_from_the_Second_Page_onwards + enable + enable + + + + + + + diff --git a/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards/Program.cs b/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards/Program.cs new file mode 100644 index 00000000..5c82d426 --- /dev/null +++ b/Table/PdfGrid/Changing-Margins-from-the-Second-Page-onwards/.NET/Changing-Margins-from-the-Second-Page-onwards/Program.cs @@ -0,0 +1,52 @@ +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; +using Syncfusion.Drawing; + +// Create PDF document +PdfDocument document = new PdfDocument(); + +// Configure marginless page layout +document.PageSettings.Margins.Top = 0; +document.PageSettings.Margins.Bottom = 0; + +// Add first page to the document +PdfPage page = document.Pages.Add(); + +// Initialize grid component for data presentation +PdfGrid pdfGrid = new PdfGrid(); + +// Generate sample data (300 rows) +List data = new List(); +for (int i = 0; i < 100; i++) +{ + // Create three unique rows per iteration + data.Add(new { ID = "1", Name = "Clay", Price = "$10" }); + data.Add(new { ID = "2", Name = "Gray", Price = "$20" }); + data.Add(new { ID = "3", Name = "Ash", Price = "$30" }); +} + +// Configure grid data binding +pdfGrid.DataSource = data; // Automatic conversion to IEnumerable + +// Set up grid layout with header space +PdfGridLayoutFormat format = new PdfGridLayoutFormat +{ + PaginateBounds = new RectangleF(0, 15, + page.GetClientSize().Width, + page.GetClientSize().Height - 15) +}; + +// Render grid to page with automatic pagination +pdfGrid.Draw(page, new RectangleF(0, 0, + page.GetClientSize().Width, + page.GetClientSize().Height), format); + +//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); +} + +// Proper document cleanup +document.Close(true); \ No newline at end of file