Free Support Forum - aspose.com

GetHeight method on a table breaks its rendering

Hi everyone,

when I build a table with colspans and rowspans greater than one and apply the method GetHeight() on my table, the rendering of the table is broken. See for instance the code below in C#/.NET 3.5.
Am I missing something here ? Please help use, it would be of great benefit for us to have this feature working.

Sincerly

public void TestMethod1()
{
var table = new Table();
table.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.3F);
var widths = "25 50 35 50 ";
table.ColumnWidths = widths;

var row1 = table.Rows.Add();
AddCell(row1,“cell1”,1,1);
AddCell(row1,“cell2”,2,1);
AddCell(row1,“cell3”,1,1);

var row2 = table.Rows.Add();
AddCell(row2,“cell4”,1,1);
AddCell(row2,“cell5”,1,1);
AddCell(row2,“cell6”,1,1);
AddCell(row2,“cell7”,1,1);

var row3 = table.Rows.Add();
AddCell(row3,“cell8”,1,2);
AddCell(row3,“cell9”,1,1);
AddCell(row3,“cell10”,2,2);

var row4 = table.Rows.Add();
AddCell(row4,“cell11”,1,1);

var pdf = new Pdf();
var section = pdf.Sections.Add();
section.Paragraphs.Add(table);

//comment/uncomment this line to see bug appear
table.GetHeight(pdf);

pdf.Save(“asposeXTable.pdf”);
}

public static void AddCell(Row row, string text, int colSpan, int rowSpan)
{
var cell = row.Cells.Add(text);
cell.RowSpan = rowSpan;
cell.ColumnsSpan = colSpan;
}

Hi Olivier,

Thanks for sharing the sample source code with us.

I tested the scenario and able to notice the same problem. For rectification, I logged this problem with ID: PDFNEWNET-33901 in our Issue Tracking System. We will further look into the details of this issue and will keep you updated via this forum thread on the status of correction.

We apologize for your inconvenience.

Thanks & Regards,

Hi Olivier,


Thanks for your patience.

I am pleased to share that the issue reported earlier has been resolved. We are about to release the new version of Aspose.Pdf for .NET 7.8.0 which will include the resolution of issue reported earlier. Furthermore, I would recommend you to please try using the following code snippet to fulfill your requirement.

[C#]

Document doc = new
Document();<o:p></o:p>

Page page = doc.Pages.Add();

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.3F);

string widths = "25 50 35 50 ";

table.ColumnWidths = widths;

Aspose.Pdf.Row row1 = table.Rows.Add();

AddCell(row1, "cell1", 1, 1);

AddCell(row1, "cell2", 2, 1);

AddCell(row1, "cell3", 1, 1);

Aspose.Pdf.Row row2 = table.Rows.Add();

AddCell(row2, "cell4", 1, 1);

AddCell(row2, "cell5", 1, 1);

AddCell(row2, "cell6", 1, 1);

AddCell(row2, "cell7", 1, 1);

Aspose.Pdf.Row row3 = table.Rows.Add();

AddCell(row3, "cell8", 1, 2);

AddCell(row3, "cell9", 1, 1);

AddCell(row3, "cell10", 2, 2);

Aspose.Pdf.Row row4 = table.Rows.Add();

AddCell(row4, "cell11", 1, 1);

page.Paragraphs.Add(table);

//comment/uncomment this line to see bug appear

table.GetHeight();

doc.Save("c:/pdftest/HeightIssue.pdf");

public void AddCell(Aspose.Pdf.Row row, string text, int colSpan, int rowSpan)

{ Aspose.Pdf.Cell
cell = row.Cells.Add(text); cell.RowSpan = rowSpan; cell.ColSpan = colSpan; }

The issues you have found earlier (filed as PDFNEWNET-33901) have been fixed in Aspose.Pdf for .NET 7.8.0update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.