From 9948adc1d20d5f4f467dd4cf8085843636a76c53 Mon Sep 17 00:00:00 2001 From: SreemonPremkumarMuthukrishnan Date: Wed, 22 Oct 2025 10:49:46 +0530 Subject: [PATCH 1/3] ES-975464 - Resolve ReadMe Length Issues in this repository --- README.md | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 14f5f37..ed1342c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,37 @@ -# How-to-set-page-breaks-while-exporting-GridControl-to-pdf -This example demonstrates how to set page breaks while exporting [GridControl](https://help.syncfusion.com/windowsforms/grid/getting-started?utm_medium=listing&utm_source=github-examples) to PDF. -See [How to set page breaks while exporting GridControl to pdf?](https://www.syncfusion.com/kb/9635?utm_medium=listing&utm_source=github-examples) for more details. +# How to Set Page Breaks While Exporting WinForms GridControl to PDF? + +This example demonstrates how to set page breaks while exporting [WinForms GridControl](https://www.syncfusion.com/winforms-ui-controls/grid-control) to PDF. + +Page breaks can be set while exporting GridControl as PDF by passing row count for each PDF page in the [GridPDFConverter.ExportToPdf](https://help.syncfusion.com/cr/windowsforms/Syncfusion.GridHelperClasses.GridPDFConverter.html#Syncfusion_GridHelperClasses_GridPDFConverter_ExportToPdf_Syncfusion_Pdf_PdfDocument_Syncfusion_Windows_Forms_Grid_GridControlBase_Syncfusion_Windows_Forms_Grid_GridRangeInfo_) method. The PDF pages are merged as a single PDF file and finally saved. + +``` csharp +private void Exportbutton_Click(object sender, EventArgs e) +{ + var converter = new GridPDFConverter(); + var lowest = 0; + + //Adding page breaks to a list. + var rows = new List {30, 63, 90, 130, 150}; + + var pdfDocument = new PdfDocument(); + pdfDocument.Save("Sample.pdf"); + foreach (var rownumber in rows) + { + var pdf = new PdfDocument(); + var maximumRow = rownumber; + converter.ExportToPdf(pdf, gridControl1, GridRangeInfo.Rows(lowest, maximumRow)); + var stream = new MemoryStream(); + pdf.Save(stream); + var loadedDocument = new PdfLoadedDocument("Sample.pdf"); + loadedDocument = PdfDocumentBase.Merge(loadedDocument, new PdfLoadedDocument(stream)) as PdfLoadedDocument; + loadedDocument.Save("Sample.pdf"); + loadedDocument.Close(true); + stream.Dispose(); + lowest = maximumRow + 1; + } + var loadedDocument1 = new PdfLoadedDocument("Sample.pdf"); + loadedDocument1.Pages.RemoveAt(0); + loadedDocument1.Save("Sample.pdf"); + Process.Start("Sample.pdf"); +} +``` \ No newline at end of file From 843a992ae27abbeddcc8f2b3110b0c1ea7153669 Mon Sep 17 00:00:00 2001 From: SreemonPremkumarM Date: Wed, 22 Oct 2025 22:54:27 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed1342c..00c2dbe 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,6 @@ private void Exportbutton_Click(object sender, EventArgs e) loadedDocument1.Save("Sample.pdf"); Process.Start("Sample.pdf"); } -``` \ No newline at end of file +``` + +Take a moment to peruse the [WinForms GridControl - PDF Exporting](https://help.syncfusion.com/windowsforms/grid-control/exporting#pdf-exporting) documentation, where you can find about GridControl with code examples. From 6ef2a711c9d7b1407dba79679bf36140b7b6cd8b Mon Sep 17 00:00:00 2001 From: SreemonPremkumarM Date: Tue, 28 Oct 2025 00:45:09 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00c2dbe..51e4401 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,4 @@ private void Exportbutton_Click(object sender, EventArgs e) } ``` -Take a moment to peruse the [WinForms GridControl - PDF Exporting](https://help.syncfusion.com/windowsforms/grid-control/exporting#pdf-exporting) documentation, where you can find about GridControl with code examples. +Take a moment to peruse the [WinForms GridControl - PDF Exporting](https://help.syncfusion.com/windowsforms/grid-control/exporting#pdf-exporting) documentation, where you can find about PDF exporting with code examples.