BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
I read follows links:
https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Graphics.PdfLayoutBreakType.html
https://www.syncfusion.com/forums/130150/pdf-keep-rows-together
I try the code from first link. and I made change to ElementFit and I add some text, as you can see bellow.
But is not work. the rendered PDF keep split the Row 3 between pages. Like that:
So how I can keep row in one page?
Here the code:
for
(int i = 20; i > 0; i--)
{
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
dataTable.Rows.Add(new object[] { "E03", "George Scanning to pdf on Windows 10 is an easy process with the right tools.Whether you use built-in software, download a free scanning program, or use an online scanner, you can quickly and easily create high - quality pdf files from your physical documents.For those who want a comprehensive and versatile solution for working with pdfs, we recommend downloading WPS Office, which offers a full suite of tools for editing, converting, and managing pdf files.With its intuitive interface and powerful features, WPS Office is a top choice for users who want to streamline their pdf workflow.Download WPS Office today and see how it can improve your pdf experience." });
dataTable.Rows.Add(new object[] { "E04", "Stefan" });
dataTable.Rows.Add(new object[] { "E05", "Mathew" });
}
//Assign data source.
table.DataSource = dataTable;
//Create new PDF layout format instance.
PdfLayoutFormat format = new PdfLayoutFormat();
//Set page break.
format.Break = PdfLayoutBreakType.FitElement;
//Set layout type.
format.Layout = PdfLayoutType.Paginate;
//Set paginate bounds.
format.PaginateBounds = new RectangleF(0, 0, 500, 350);
//Draw grid to the page of PDF document.
table.Draw(page, new RectangleF(0, 0, 500, 700), format);
After analyzing your query, we can ensure that the row remains in one page by setting the AllowRowBreakAcrossPages property of PdfGrid to false. By default, AllowRowBreakAcrossPages is set to true, indicating whether rows can be split across pages. After changing AllowRowBreakAcrossPages to false, it performs as expected. Please refer the code example below,
//Create a PdfGrid.
PdfGrid table = new PdfGrid();
table.AllowRowBreakAcrossPages = false;
Please try the above solution on your end and inform us the outcome.
Thanks.
So what the effect have for:
format.Break = PdfLayoutBreakType.FitElement;
Also what the different between the follow two classes(Regard to Grid.Draw) :
PdfGridLayoutFormat
and
PdfLayoutFormat
?
Hi Matanya,
By setting the Break property to PdfLayoutBreakType.FitElement, you ensure that each table is fully contained on a single page. If the table doesn't fit, it will start on the next page instead of being split.
Please refer to the API documentation for further details:
Enum PdfLayoutBreakType - FileFormats API Reference | Syncfusion
Regards,
Jeyalakshmi T
I try bellow code with PdfLayoutBreakType.FitElement, But the table still split over two pages:
static PdfDocument pdfExmpl6()
{
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfGrid table = new PdfGrid();
DataTable dataTable = new DataTable();
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
dataTable.Rows.Add(new object[] { "E03", "George Scanning to pdf on Windows 10 is an easy process with the right tools.Whether you use built-in software, download a free scanning program, or use an online scanner, you can quickly and easily create high - quality pdf files from your physical documents.For those who want a comprehensive and versatile solution for working with pdfs, we recommend downloading WPS Office, which offers a full suite of tools for editing, converting, and managing pdf files.With its intuitive interface and powerful features, WPS Office is a top choice for users who want to streamline their pdf workflow.Download WPS Office today and see how it can improve your pdf experience." });
dataTable.Rows.Add(new object[] { "E04", "Stefan" });
dataTable.Rows.Add(new object[] { "E05", "Mathew" });
dataTable.Rows.Add(new object[] { "E01 - 2", "Clay" });
dataTable.Rows.Add(new object[] { "E02 - 2", "Thomas" });
dataTable.Rows.Add(new object[] { "E03 - 2", "George Scanning to pdf on Windows 10 is an easy process with the right tools.Whether you use built-in software, download a free scanning program, or use an online scanner, you can quickly and easily create high - quality pdf files from your physical documents.For those who want a comprehensive and versatile solution for working with pdfs, we recommend downloading WPS Office, which offers a full suite of tools for editing, converting, and managing pdf files.With its intuitive interface and powerful features, WPS Office is a top choice for users who want to streamline their pdf workflow.Download WPS Office today and see how it can improve your pdf experience." });
dataTable.Rows.Add(new object[] { "E04 - 2", "Stefan" });
dataTable.Rows.Add(new object[] { "E05 - 2", "Mathew" });
dataTable.Rows.Add(new object[] { "E01 - 3", "Clay" });
dataTable.Rows.Add(new object[] { "E02 - 3", "Thomas" });
dataTable.Rows.Add(new object[] { "E03 - 3", "George Scanning to pdf on Windows 10 is an easy process with the right tools.Whether you use built-in software, download a free scanning program, or use an online scanner, you can quickly and easily create high - quality pdf files from your physical documents.For those who want a comprehensive and versatile solution for working with pdfs, we recommend downloading WPS Office, which offers a full suite of tools for editing, converting, and managing pdf files.With its intuitive interface and powerful features, WPS Office is a top choice for users who want to streamline their pdf workflow.Download WPS Office today and see how it can improve your pdf experience." });
dataTable.Rows.Add(new object[] { "E04 - 3", "Stefan" });
dataTable.Rows.Add(new object[] { "E05 - 3", "Mathew" });
table.DataSource = dataTable;
PdfGridLayoutFormat format = new PdfGridLayoutFormat();
format.Break = PdfLayoutBreakType.FitElement;
format.Layout = PdfLayoutType.Paginate;
table.AllowRowBreakAcrossPages = false;
table.Draw(page, new RectangleF(0, 300, 500, 700), format);
return doc;
}
Hi Matanya,
PdfLayoutBreakType.FitElement: The content will be adjusted to ensure that each element (such as a paragraph or image) fits entirely on a page. If an element cannot fit on the current page, it will be moved to the next page.
In your case, you have drawn the grid starting from the position (x:0, y:300). As a result, the table is split over to the second page. To draw the table on a single page, you can adjust the x and y positions. We suggest that you draw the table from the position (x:0, y:0).
PdfLayoutType.Paginate: content flows across multiple pages, automatically breaking content to fit within page boundaries.
When using PageLayoutType.OnePage, this property ensures that all fit elements are drawn on a single page without moving to the next page.
Regards,
Jeyalakshmi T
I ask above what effect have for follow code:
PdfGridLayoutFormat format = new PdfGridLayoutFormat();
format.Break = PdfLayoutBreakType.FitElement;
Your answer:
By setting the Break property to PdfLayoutBreakType.FitElement, you ensure that each table is fully contained on a single page. If the table doesn't fit, it will start on the next page instead of being split.
That not exactly my case?
Hi Matanya,
Currently, we are working on this and will update further details on July 22, 2024.
Regards,
Jeyalakshmi T
Hi Matanya,
Thankyou for you patience,
The reported issues still need a lot more in-depth research; thus, we are looking into them. On July 24th, 2024, further information will be updated.
Regards,
Raashith Ahamed S
We have confirmed the issue “Grid is splitted after assigning layoutbreaktype FitElement” as a defect in our product and we will include the fix in weekly release on 13th August 2024
Please use the below feedback link to track the status of the reported bug.
Note: If you require a patch for the reported issue in any of our Essential Studio Main or SP release version, then kindly let us know the version, so that we can provide a patch in that version based on our SLA policy.
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”
Hi Matanya,
We were unable to include the fix for the issue "Grid is splitted after assigning layoutbreaktype FitElement" as promised in the weekly release scheduled to be published tomorrow (13/08/2024). This fix will be included in the next weekly release (20/08/2024).
If you would like to verify the fix before the next release, we can provide you with a custom patch. Please let us know if you are interested.
We apologize for any inconvenience this may have caused and appreciate your understanding.
Regards,
Raashith Ahamed S
Hi Matanya,
Sorry for the inconvenience caused,
Due to complexity ,We were unable to include the fix for the issue “Grid is splitted after assigning layoutbreaktype FitElement” as promised in the weekly release. This fix will be included in the next weekly release (27/08/2024).
If you would like to verify the fix before the next release, we can provide you with a custom patch. Please let us know if you are interested.
We apologize for any inconvenience this may have caused and appreciate your understanding.
Regards,
Raashith Ahamed S
Hi Matanya,
Thank you for your patience.
After a detailed analysis, we found that the current behavior of the FitElement feature is that if an element does not fit on the page, it will not be drawn. This applies to elements like text element. However, for grids, we cannot apply the FitElement behavior because grids are rendered row by row. If you want to prevent rows from splitting, you can disable the AllowRowBreakAcrossPages option.
Applying the FitElement behavior to grids would impact performance when measuring large grids and could lead to the loss of cell content if it doesn't fit on the page. Therefore, we cannot proceed with this approach.
To help you understand the FitElement functionality better, we have provided a code example using PdfTextElement for your reference.
PdfDocument document = new PdfDocument();
//Add page to the document
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
string text = "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base.";
//Create a text element with the text and font
PdfLayoutFormat format = new PdfLayoutFormat();
format.Break = PdfLayoutBreakType.FitElement;
format.Layout = PdfLayoutType.Paginate;
PdfTextElement textElement = new PdfTextElement(text, new PdfStandardFont(PdfFontFamily.TimesRoman, 14));
//Draw the text in the first column
textElement.Draw(page, new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height),format);
//Creating the stream object
MemoryStream stream = new MemoryStream();
//Save the document into memory stream
document.Save(stream);
File.WriteAllBytes("fitelement.pdf", stream.ToArray());
//Close the document.
document.Close(true);
FitElement (if text is not fit on the first page,it will automaticaly draw the text to other page) |
|
FitPage (if text is not fit on the first page,it will paginate to other page) |
|
Regards,
RaashithAhamed