In attached pdf, footer grid overlaps with the grid above using following code:
PdfDocument document = new PdfDocument();
var brush = new PdfSolidBrush(System.Drawing.Color.Black);
var font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 10), true);
var section = document.Sections.Add();
section.PageSettings.Size = PdfPageSize.A4;
section.PageSettings.Orientation = PdfPageOrientation.Portrait;
section.PageSettings.Size = PdfPageSize.A4;
section.PageSettings.SetMargins(17, 17, 17, 17);
var page = section.Pages.Add();
// Set page numbers
PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush);
PdfPageCountField count = new PdfPageCountField(font, brush);
System.Drawing.RectangleF bounds = new System.Drawing.RectangleF(0, 0, page.GetClientSize().Width - 34, 20);
PdfPageTemplateElement footer = new PdfPageTemplateElement(bounds)
{
Y = bounds.Y // Workaround for bug in Syncfusion 19.3460.0.53: when setting bounds, Y coordinate is not set from constructor.
};
PdfCompositeField compositeField = new PdfCompositeField(font, brush, "{0} of {1}", pageNumber, count)
{
StringFormat = new PdfStringFormat(PdfTextAlignment.Left),
Bounds = footer.Bounds
};
compositeField.Draw(footer.Graphics, new System.Drawing.PointF(0, 10));
section.Template.Bottom = footer;
// Page content
var layoutFormat = new PdfLayoutFormat
{ Break = PdfLayoutBreakType.FitElement, Layout = PdfLayoutType.Paginate };
// Root grid 3x1
var rootGrid = new PdfGrid();
rootGrid.Style.CellPadding.All = 10;
var rootColumn = rootGrid.Columns.Add();
rootColumn.Width = page.GetClientSize().Width;
var rootFirstRow = rootGrid.Rows.Add();
//rootFirstRow.Height = 20;
var rootSecondRow = rootGrid.Rows.Add();
//rootSecondRow.Height = 20;
var rootThirdRow = rootGrid.Rows.Add();
//rootThirdRow.Height = 20;
// First inner grid 3x3
var rootFirstRowCell = rootFirstRow.Cells[0];
rootFirstRowCell.Style.Borders.All = PdfPens.Green;
var firstInnerGrid = new PdfGrid();
firstInnerGrid.AllowRowBreakAcrossPages = true;
firstInnerGrid.Style.CellSpacing = 0;
firstInnerGrid.Style.CellPadding.All = 10;
var firstInnerGridColumn1 = firstInnerGrid.Columns.Add();
firstInnerGridColumn1.Width = 100;
var firstInnerGridColumn2 =firstInnerGrid.Columns.Add();
firstInnerGridColumn2.Width = 100;
var firstInnerGridColumn3 = firstInnerGrid.Columns.Add();
firstInnerGridColumn3.Width = 100;
var firstInnerGridFirstRow = firstInnerGrid.Rows.Add();
//firstInnerGridFirstRow.Height = 20;
firstInnerGridFirstRow.Cells[0].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
firstInnerGridFirstRow.Cells[1].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
firstInnerGridFirstRow.Cells[2].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
var firstInnerGridSecondRow = firstInnerGrid.Rows.Add();
//firstInnerGridSecondRow.Height = 20;
firstInnerGridSecondRow.Cells[0].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
firstInnerGridSecondRow.Cells[1].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
firstInnerGridSecondRow.Cells[2].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
var firstInnerGridThirdRow = firstInnerGrid.Rows.Add();
//firstInnerGridThirdRow.Height = 20;
firstInnerGridThirdRow.Cells[0].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
firstInnerGridThirdRow.Cells[1].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
firstInnerGridThirdRow.Cells[2].Value = "HEADING VERY VERY VERY LONG TO CAUSE WRAPPING";
rootFirstRowCell.Value = firstInnerGrid;
// Second inner grid 78x4
var rootSecondRowCell =rootSecondRow.Cells[0];
rootSecondRowCell.Style.Borders.All = PdfPens.Aqua;
var secondInnerGrid = new PdfGrid();
secondInnerGrid.AllowRowBreakAcrossPages = true;
secondInnerGrid.Style.CellPadding.All = 10;
secondInnerGrid.Columns.Add().Width = 5;
secondInnerGrid.Columns.Add().Width = 100;
secondInnerGrid.Columns.Add().Width = 100;
secondInnerGrid.Columns.Add().Width = 200;
for (int rowIndex = 1; rowIndex <= 78; rowIndex++)
{
var row = secondInnerGrid.Rows.Add();
if (rowIndex != 11 && rowIndex != 21 && rowIndex != 31 && rowIndex != 41 && rowIndex != 51 && rowIndex != 61)
{
//row.Cells[0].Value = $"VALUE {rowIndex}";
row.Cells[1].Value = $"VALUE {rowIndex}";
row.Cells[2].Value = $"VALUE {rowIndex}";
row.Cells[3].Value = $"VALUE {rowIndex}";
row.Height = 30;
}
}
rootSecondRowCell.Value = secondInnerGrid;
// Third grid 1x2
var rootThirdRowCell = rootThirdRow.Cells[0];
rootThirdRowCell.Style.Borders.All = PdfPens.Red;
rootThirdRowCell.Style = new PdfGridCellStyle(){ CellPadding = new PdfPaddings(0,0,0,0)};
var thirdInnerGrid = new PdfGrid();
thirdInnerGrid.AllowRowBreakAcrossPages = true;
thirdInnerGrid.Style.CellPadding.All = 10;
thirdInnerGrid.Columns.Add();
thirdInnerGrid.Columns.Add();
var thirdInnerGridRow = thirdInnerGrid.Rows.Add();
thirdInnerGridRow.Height = 20;
thirdInnerGridRow.Cells[0].Value = "FOOTER";
thirdInnerGridRow.Cells[1].Value = "FOOTER";
rootThirdRowCell.Value = thirdInnerGrid;
rootGrid.Draw(page, new System.Drawing.PointF(0, 0), layoutFormat);
using (FileStream stream = new FileStream("C:\\Test.pdf", FileMode.Create, FileAccess.ReadWrite))
{
document.Save(stream);
}
document.Close(true);
Attachment: Test2_3058aa5a.zip
Hi umlprog
Since our 2022 volume 1 main
release was rolled out yesterday, we do not have the weekly NuGet release
today. We have created a custom NuGet package with a reported fix for the issue
“Grid Cell overlapping issue occurs when drawing a PDF grid with nested
grid on a multi-page document” in this version (v20.1.0.47).
We will include the fix for the reported issue in our upcoming weekly
NuGet release, which we excepted on April 12th 2022.
Please use the below link to download our custom NuGet package,
https://www.syncfusion.com/downloads/support/forum/173841/ze/PackageWF_V20.1.0.471749840420.zip
Please refer to the below KB steps to install the custom NuGet package,
https://www.syncfusion.com/kb/11556/how-to-install-the-customer-patch-nuget-in-windows-machine
Please let us know if you need any further assistance in this.
Regards,
Gowthamraj K
Hi umlprog,
We have included the fix for the reported issue “Grid Cell overlapping issue occurs when drawing a PDF grid with nested grid on a multi-page document” in our latest weekly NuGet release (v20.1.0.48). Please use the below link to download our latest weekly NuGet,
https://www.nuget.org/packages/Syncfusion.Pdf.WinForms/20.1.0.48
Please let us know if you have any concerns on this
Regards,
Gowthamraj K