How to get the real table cell width?


#1

Hi

is there a way to get a table cell width once created?

I have a function that builds a PDF Table passing it to another function which should read the cells width to create the same table for the Aspose.Powerpoint.

Using your sample:

Pdf pdf1 = new Pdf();

Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
sec1.Paragraphs.Add(table1);
table1.ColumnWidths = "70% 30%";

Row row1 = table1.Rows.Add();

Cell cell1Row1 = row1.Cells.Add("ColumnsSpan = 2");
cell1Row1.ColumnsSpan = 2;
cell1Row1.Border = new BorderInfo((int)BorderSide.All,0.5F);

Row row2 = table1.Rows.Add();

Cell cell1Row2 = row2.Cells.Add("cell1");
cell1Row2.Border = new BorderInfo((int)BorderSide.All,0.5F);

Cell cell2Row2 = row2.Cells.Add("cell2");
cell2Row2.Border = new BorderInfo((int)BorderSide.All,0.5F,new Aspose.Pdf.Color("Red"));

pdf1.Save(...);

How to get cell1Row2 or cell2Row2 width? Note that I used a percentage to specify the Columns width.

I tried to use the FitWidth with no lucky.

Thanks

vmax


#2

Dear vmax,

Thank you for considering Aspose.

The cell width is calculated in the Save() method. So you have to calculate the cell width by yourself. The width of cell1Row2 is :

(PageWidth - PargeMarginLeft - PageMarginRight - TableMarginLeft - TableMarginRight) * 70%