Skip to content

Commit e291ec7

Browse files
Merge pull request #162 from SyncfusionExamples/957009
957009 Added the prevent row breaks across pages sample
2 parents e627fa0 + 079d24c commit e291ec7

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
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}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E4E15F07-0BAC-4D85-8F8E-19D1CCEBE4A4}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

Table/PdfGrid/Prevent-row-breaks-across-pages/.NET/Prevent-row-breaks-across-pages/Output/gitkeep.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Prevent_row_breaks_across_pages</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Syncfusion.Pdf.Grid;
2+
using Syncfusion.Pdf;
3+
4+
// Create a new PDF document
5+
using (PdfDocument document = new PdfDocument())
6+
{
7+
// Add a page
8+
PdfPage page = document.Pages.Add();
9+
10+
//Create a PdfGrid.
11+
PdfGrid pdfGrid = new PdfGrid();
12+
// Create a list with multiple short rows and one very large row
13+
var data = new List<object>
14+
{
15+
new { ID = "E01", Description = "Short text 1" },
16+
new { ID = "E02", Description = "Short text 2" },
17+
new
18+
{
19+
ID = "E03",
20+
Description = new string('A', 5000)
21+
},
22+
new { ID = "E04", Description = "Short text 3" }
23+
};
24+
25+
// Assign the list as the data source
26+
pdfGrid.DataSource = data;
27+
28+
// Prevent row breaking across pages
29+
pdfGrid.AllowRowBreakAcrossPages = false;
30+
31+
// Draw the grid on the page
32+
pdfGrid.Draw(page, new Syncfusion.Drawing.PointF(0, 0));
33+
34+
//Create file stream.
35+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
36+
{
37+
//Save the PDF document to file stream.
38+
document.Save(outputFileStream);
39+
}
40+
}

0 commit comments

Comments
 (0)