We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Wide PDF Table: Colspan Text Duplicated

When I have a wide-PDF-table with a colspan that exists across the page-break, I have found an issue where the text of the colspan gets duplicated. See the attached code to reproduce:

        var doc = new Document();
        var page = doc.Pages.Add();
        page.PageInfo.Margin = new MarginInfo(0.375, 0.375, 0.375, 0.375);
        var mytable = new Table {Broken = TableBroken.Vertical};
        page.Paragraphs.Add(mytable);

        mytable.ColumnWidths = "116.25 55.8 55.8 55.8 55.8 69.75 69.75 69.75 55.8 55.8 55.8 55.8";
        mytable.RepeatingRowsCount = 3;
        var numCols = 12;

        var headerRow = mytable.Rows.Add();
        for (var i=0; i<3; i++)
        {
            headerRow.Cells.Add("Estimate Column " + i);
        }
        headerRow.Cells[1].ColSpan = 5;

        headerRow.Cells[2].DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        headerRow.Cells[2].ColSpan = 6;

        
        for (var rowCounter = 0; rowCounter <= 85; rowCounter++)
        {
            var row = mytable.Rows.Add();
            for (var colCounter = 0; colCounter < numCols; colCounter++)
            {
                row.Cells.Add("row" + rowCounter.ToString() + ", col" + colCounter.ToString());
            }
        }

        doc.Save("TextAlignmentColspanWideTableError.pdf");

In the corresponding PDF generated by this code, we see that the text “Estimate Column 2” does not appear on page 1, but appears on pages 3 and 4 (as it probably should) and is duplicated on page 2. It is incorrect for that cell text to be duplicated, as the columns after the break (pages 3 and 4) already contain that cell text. I am attaching the PDF for your reference as well.

TextAlignmentColspanWideTableError.pdf (51.1 KB)

@dfactset

Thanks for contacting support.

We were able to reproduce the issue in our environment, while testing the scenario using your code snippet. Therefore, we have logged this issue as PDFNET-44958 in our issue management system. We will further investigate issue in details and keep you updated with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hello,

Are there any updates on the status of this issue?

Thank you.

@dfactset

Thanks for your inquiry.

I am afraid that earlier logged issue is not yet resolved due to other pending issues in the queue. Since the issue was logged under free support model, it has low priority and will be resolved/fixed on first come first serve basis. As soon as we have some definite updates regarding issue resolution, we will let you know. Please spare us little time.

We are sorry for the inconvenience.

Hi,

I found out some more details regarding this issue which I think may help in your investigation.

Using the reproducer above, if you change the horizontal alignment in this line:
headerRow.Cells[2].DefaultCellTextState.HorizontalAlignment =
to be HorizontalAlignment.Right, then something different happens. In this case, the text gets right aligned to the page rather than the colspan. So “Estimate Column 2” shows up on pages 1 and 2, where it shouldn’t be, since the colspan is split onto pages 3 and 4, and “Estimate Column 2” does not appear on pages 3 and 4, where it should. I’m attaching the generated PDF so you can see what I mean. Hopefully it helps a bit.

TextAlignmentColspanWideTableErrorRIGHTALIGN.pdf (58.7 KB)

If you change the horizontal alignment property to “HorizontalAlignment.Left”, then the output is correct, because the left portion of the colspan is split to pages 1 and 2 of the document. So this issue may be related to how horizontal alignment is treated when it’s over a merged cell that occurs over the wide table break – the alignment focuses on the boundary of the page rather than the true boundary of the colspan.

Hope it helps.

@dfactset

Thanks for sharing your findings with us.

We have recorded these findings along with the issue and they surely will be helpful during investigation. As soon as we have some updates about investigation results, we will let you know.

The issues you have found earlier (filed as PDFNET-44958) have been fixed in Aspose.PDF for .NET 20.1.