Dear Sirs
I have trouble fixing the row height on a table using rowpan. In my sample (see below), I have tables with two rows and three columns. First and third columns contain one cell (using rowspan = 2), and second column (middle) have two cells (without rowspan).
I try to set the height only for one row (first one, but does not work with the second either) in order to have first row with a height fixed at 15 points, and second row with dynamic height based on content of the third column.
The results are not what I expected : fixed row height is the second row not on the first one. If I try to set row height of the second one, neither of the two rows is fixed in height.
Below sample code with three tables :
1/ standard table (without using rowpsan) => it is ok.
2/ table using rowspan with first row fixed height to 15 points => KO
3/ table using rowspan with second row fixed height to 15 points => KO
Private Sub TestHeightMergeRow()
Dim pdf = New Document
Dim page = pdf.Pages.Add()'first sample standard table with 1st row fixed height InsertSpace(page, "Standard table with 1st row fixed height to 15 pts") Dim table = New Table page.Paragraphs.Add(table) table.ColumnWidths = "50 60 70" table.DefaultCellBorder = New BorderInfo(BorderSide.Box, 1) Dim row = table.Rows.Add() row.FixedRowHeight = 15 row.Cells.Add("cell 1,1") row.Cells.Add("cell 1,2") row.Cells.Add("cell 1,3 zjedljezd lzejdlzkjed rzfjekrjf elrjf") row = table.Rows.Add() row.Cells.Add("cell 2,1") row.Cells.Add("cell 2,2") row.Cells.Add("cell 2,3 zjedljezd lzejdlzkjed rzfjekrjf elrjf") 'space between the 2 tables InsertSpace(page, "Table with rowspan using height of 15 pts for the first row : KO => first row must have height of 15 points, whereas it's the second row which has this fixed height....") 'Second sample : problem with Height => first row must have height of 15 points, whereas it's the second row which has this fixed height.... table = New Table page.Paragraphs.Add(table) table.ColumnWidths = "80 80 80" table.DefaultCellBorder = New BorderInfo(BorderSide.Box, 1, Aspose.Pdf.Color.DarkRed) row = table.Rows.Add() row.FixedRowHeight = 15 Dim cell = row.Cells.Add("cell 1-2,1") cell.RowSpan = 2 row.Cells.Add("cell 1,2") cell = row.Cells.Add("cell 1-2,3 zrfjozirejfoi zoeifjoziejf oziejfoziejf zoiejfozjef") cell.RowSpan = 2 row = table.Rows.Add() row.Cells.Add("cell 2,2") 'space between the 2 tables InsertSpace(page, "Same example as above with second row height fixed to 15 pts => KO, the two rows seems to be dynamic height in terms of content of the third cell.") 'Third sample table = New Table page.Paragraphs.Add(table) table.ColumnWidths = "80 80 80" table.DefaultCellBorder = New BorderInfo(BorderSide.Box, 1, Aspose.Pdf.Color.DarkRed) row = table.Rows.Add() cell = row.Cells.Add("cell 1-2,1") cell.RowSpan = 2 row.Cells.Add("cell 1,2") cell = row.Cells.Add("cell 1-2,3 zrfjozirejfoi zoeifjoziejf oziejfoziejf zoiejfozjef") cell.RowSpan = 2 row = table.Rows.Add() row.Cells.Add("cell 2,2") row.FixedRowHeight = 15 'save generated pdf file pdf.Save($"C:\temp\testHeightMergeCell.pdf") Process.Start($"C:\temp\testHeightMergeCell.pdf") End Sub Private Sub InsertSpace(page As Page, msg As String) Dim table = New Table() page.Paragraphs.Add(table) table.DefaultCellBorder = New BorderInfo(BorderSide.Box, 0) table.ColumnWidths="600" table.DefaultCellPadding = New MarginInfo(0,5,0,0) Dim row = table.Rows.Add() row.FixedRowHeight = 50 Dim cell = row.Cells.Add(msg) cell.VerticalAlignment=VerticalAlignment.Bottom cell.Alignment = HorizontalAlignment.Left cell.DefaultCellTextState.FontStyle = FontStyles.Bold End Sub
Here the generated PDF of the above sample : testHeightMergeCell.pdf (2.9 KB)
How can I get the expected results ?
Best Regards
Fabien F.