Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Aug 31, 2021 11:24 pm

We are having trouble with nested grids which span multiple pages and the content of the child grids not being drawn once it spans to the next page. When a cell containing a grid spans a page break it allocates the correct space for the content, but the child grid doesn't render after the break

We are currently using Spire PDF v7.8.8

sentrichr
 
Posts: 13
Joined: Tue Jul 24, 2018 1:16 pm

Wed Sep 01, 2021 9:28 am

Hi,

Thank you for your inquiry.
To resolve the issue you mentioned, please set the AllowCrossPages property of row as false. The reference code is as follows:
Code: Select all
…
var row = layoutGrid.Rows.Add();
row.AllowCrossPages = false;
var grid = new Grid(3, layoutGrid.Columns[0].Width);
...

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Sep 01, 2021 3:40 pm

Thank you for your quick response, however setting AllowCrossPage to false on the row doesn't really resolve the display issue. If I do that, whenever there is a row that won't entirely fit on the current page it just skips to the next page leaving potentially a lot of empty space at the end of the prior page. This is similar to what's reported for SPIREPDF-3355. Also, if any single row is taller than a page setting AllowCrossPage to false will mean that row doesn't display at all.

Here's an example of row being taller than a page with AllowCrossPage set to false. If you make this change in the previously attached code it will just generate a pdf with a bunch of empty pages.

var row = layoutGrid.Rows.Add();
row.AllowCrossPages = false;
var grid = new Grid(3, layoutGrid.Columns[0].Width);
var rows = 50;// new Random().Next(2, 10);
for (var y = 0; y < rows; y++)
{
for (var x = 0; x < 3; x++)
{
grid.AddCell($"Row {y+1} / {rows}, Col {x}");
}
}

The code example I gave originally is just simple example that demonstrates an issue we are seeing in our more complex example where we are create a multi-page pdf which includes grids spanning multiple pages. In our complex example, the content of the grid is based on data from an application, so the amount of data and therefore length of the grid and height of rows can vary widely. We need to be able to display that content spanning multiple pages without unnecessary blank space left at the bottom of a page and also that we do not end up with blank pages.

sentrichr
 
Posts: 13
Joined: Tue Jul 24, 2018 1:16 pm

Thu Sep 02, 2021 2:58 am

Hi,

Thank you for your feedback.
I have logged the issue into our Bug tracking system with the ticket number SPIREPDF-4616. Our development team will investigate and fix it. Once it is resolved or there is any update, I will inform you. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Sep 02, 2021 3:58 pm

Great, thank you!

sentrichr
 
Posts: 13
Joined: Tue Jul 24, 2018 1:16 pm

Fri Sep 03, 2021 10:19 am

Hi,

Thanks for your patience.
After further investigation, I found that you set a white background for outer grid and nested grid, actually the cause of your issue is that the nested grid drawn on the second page is covered by the white background of the outer grid. To resolve this issue, please do not set a white background for the outer grid. Here I made adjustment for your code, please have a check.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Sep 03, 2021 9:17 pm

Thank you for your response. Removing the white background on our grids resolves the issue in the sample application as well as our more complex real world use. However, it still seems a little odd that the top level grid's background would end up on top of its content, especially only after the first page because it works as expected on the first page a grid appears.

sentrichr
 
Posts: 13
Joined: Tue Jul 24, 2018 1:16 pm

Mon Sep 06, 2021 10:56 am

Hi,

Thanks for your feedback and sorry for the late reply as weekend.
The mechanism for drawing the grids is that our Spire.Pdf will first draw the outer grid on the first page, then draw the nested grid inside the outer grid. However, if the nested grid is across page, the priority of drawing the nest grid on the second page will be higher than drawing the outer grid, hence the background of outer grid will cover the nested grid on the second page. Hope I make it clear. If there is any question, please feel free to write back.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF

cron