diff --git a/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages.sln b/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages.sln new file mode 100644 index 00000000..24eeb17c --- /dev/null +++ b/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages.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}") = "Prevent-row-breaks-across-pages", "Prevent-row-breaks-across-pages\Prevent-row-breaks-across-pages.csproj", "{E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Output/gitkeep.txt b/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Prevent-row-breaks-across-pages.csproj b/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Prevent-row-breaks-across-pages.csproj new file mode 100644 index 00000000..d3d55ab7 --- /dev/null +++ b/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Prevent-row-breaks-across-pages.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Prevent_row_breaks_across_pages + enable + enable + + + + + + + diff --git a/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Program.cs b/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Program.cs new file mode 100644 index 00000000..4741d275 --- /dev/null +++ b/Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Program.cs @@ -0,0 +1,40 @@ +using Syncfusion.Pdf.Grid; +using Syncfusion.Pdf; + +// Create a new PDF document +using (PdfDocument document = new PdfDocument()) +{ + // Add a page + PdfPage page = document.Pages.Add(); + + //Create a PdfGrid. + PdfGrid pdfGrid = new PdfGrid(); + // Create a list with multiple short rows and one very large row + var data = new List + { + new { ID = "E01", Description = "Short text 1" }, + new { ID = "E02", Description = "Short text 2" }, + new + { + ID = "E03", + Description = new string('A', 5000) + }, + new { ID = "E04", Description = "Short text 3" } + }; + + // Assign the list as the data source + pdfGrid.DataSource = data; + + // Prevent row breaking across pages + pdfGrid.AllowRowBreakAcrossPages = false; + + // Draw the grid on the page + pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, 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); + } +}