Skip to content

957009 Added the prevent row breaks across pages sample #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Prevent_row_breaks_across_pages</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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<object>
{
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);
}
}
Loading