1.When we set row height inside PdfGrid, nested PdfGrid (child1) gets clipped. How can I make nested grid or row to autogrow?
2.Also I found strange behaviour that if we don't set row height, but simply read its Height property, content will not autogrow. (Uncomment Debug.WriteLine and comment line above it.)
`
public void CreateGrid()
{
using (PdfDocument pdfDocument = new PdfDocument())
{
//Create the page
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create the parent grid
PdfGrid pGrid = new PdfGrid();
pGrid.Columns.Add();
pGrid.Rows.Add();
pGrid.Columns[0].Width = 800;
var parentGrid = new PdfGrid();
parentGrid.Columns.Add();
parentGrid.Rows.Add();
pGrid.Rows[0].Cells[0].Value = parentGrid;
parentGrid.Rows[0].Height = 20;
//System.Diagnostics.Debug.WriteLine($"Row height: {parentGrid.Rows[0].Height}");
PdfGrid child1 = new PdfGrid();
parentGrid.Rows[0].Cells[0].Value = child1;
FillGrid(child1, "child1", 5, 5);
PdfGrid child2 = new PdfGrid();
FillGrid(child2, "child2", 5, 7);
parentGrid.Rows.Add();
parentGrid.Rows[1].Cells[0].Value = child2;
//Draw the parent PdfGrid
pGrid.Draw(pdfPage, PointF.Empty, new PdfGridLayoutFormat { Break = PdfLayoutBreakType.FitPage, Layout = PdfLayoutType.Paginate });
//Save the document
pdfDocument.Save("NestedTable.pdf");
//Close the document
pdfDocument.Close(true);
//This will open the PDF file so, the result will be seen in default PDF viewer
System.Diagnostics.Process.Start("NestedTable.pdf");
}
}
void FillGrid(PdfGrid grid, string name, int iMax, int jMax)
{
for (int j = 0; j < jMax; j++)
{
grid.Columns.Add();
grid.Columns[j].Width = 50 + 5 * j;
}
for (int i = 0; i < iMax; i++)
{
grid.Rows.Add();
for (int j = 0; j < jMax; j++)
{
var cell = grid.Rows[i].Cells[j];
cell.Value = $"grid: {name}. i:{i},j:{j}";
System.Diagnostics.Debug.WriteLine($"Height: {cell.Height}, width:{cell.Width}");
}
}
}`
We are using 19.3.0.53 NuGet version.
For now I'm forced to write
var m_isRowHeightSetField = this.row.GetType().GetField("m_isRowHeightSet", BindingFlags.Instance |
BindingFlags.Public |
BindingFlags.NonPublic);
m_isRowHeightSetField.SetValue(this.row, false);
when in code we determine that a PdfGrid will be set to a cell and from behaviour know that initially set Height will not autoincrease.
|
1.When we set row height inside PdfGrid, nested PdfGrid (child1) gets clipped. How can I make nested grid or row to autogrow? |
On our further analysis, if we set the row height in the PdfGridRow , the height will not be auto increase based on the nested grid content. The height will remain same for particular grid row for whole process. |
|
2.Also I found strange behaviour that if we don't set row height, but simply read its Height property, content will not autogrow. (Uncomment Debug.WriteLine and comment line above it.) |
This behavior occurs due to the height value is calculated before adding nested grid while getting grid row height in Debug.WriteLine. We have confirmed the issue “Cell clipping issue occurs when drawing a PDF grid with row height on nested grid” as a defect in our product. We will include the fix for this issue in our upcoming weekly NuGet release, which will be available on December 28th , 2021.
Please use the below feedback link to track the status of the reported bug.
|
So how can I make the row autoincrease? We don't know grid height in advance.
Thanks for your update. We will try your fix soon.