Hi all,
I've a problem on configuring cell/row borders. I create a pdf document in which I have a table. I write the rows using the following routine:
===================================== Public Sub AddRowTable(ByRef Table As MigraDoc.DocumentObjectModel.Tables.Table, ByVal CellContent() As String, ByVal ColsAlignment() As Integer, _ Optional ByVal Top As Single = 0, Optional ByVal PageBreak As Boolean = False, _ Optional ByVal borders() As Single = Nothing) =====Border() contain the width of border lines=====
Dim row = Table.AddRow() row.HeadingFormat = False row.Format.PageBreakBefore = PageBreak row.Format.Font.ApplyFont(_currFont)
row.Format.Borders.Top.Style = BorderStyle.Dot row.Format.Borders.Bottom.Style = BorderStyle.Dot row.Format.Borders.Left.Style = BorderStyle.Dot row.Format.Borders.Right.Style = BorderStyle.Dot row.Format.SpaceAfter = 0 row.Format.SpaceBefore = 0
If IsNothing(Borders) Then row.Format.Borders.Top.Width = 0 row.Format.Borders.Right.Width = 0 row.Format.Borders.Bottom.Width = 0 row.Format.Borders.Left.Width = 0 Else row.Format.Borders.Top.Width = Unit.FromCentimeter(Borders(0)) row.Format.Borders.Right.Width = Unit.FromCentimeter(Borders(1)) row.Format.Borders.Bottom.Width = Unit.FromCentimeter(Borders(2)) row.Format.Borders.Left.Width = Unit.FromCentimeter(Borders(3)) End If
'row.Format.SpaceBefore = Top
Dim MaxRowHeight As Single = 0
For i = 0 To CellContent.Count - 1 Dim cell = row.Cells(i)
If CellContent(i).Trim = "" Then cell.Format.Borders.Top.Width = 0 cell.Format.Borders.Right.Width = 0 cell.Format.Borders.Bottom.Width = 0 cell.Format.Borders.Left.Width = 0 End If cell.AddParagraph(CellContent(i)) cell.Format.Alignment = ColsAlignment(i)
Dim rowheight As Single
GetTextMeasure(CellContent(i)) rowheight = (_currWidth / row.Item(i).Column.Width.Centimeter) + 1 rowheight *= _currHeight
MaxRowHeight = IIf(MaxRowHeight < rowheight, rowheight, MaxRowHeight)
Next row.Height = Unit.FromCentimeter(MaxRowHeight) row.HeightRule = Tables.RowHeightRule.AtLeast
_currHeight += MaxRowHeight
End Sub =====================================
The result is the following is in the attach image. As you can see it doesn't put all the cell's borders on the same level.
I'm sure that i'wrote something wrong.....but I don't konw where!!!
Could you help me please?
Attachments: |
Cattura.PNG [ 14.75 KiB | Viewed 6259 times ]
|
|