PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Apr 30, 2024 5:44 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Apr 01, 2015 6:15 pm 
Offline

Joined: Thu Mar 26, 2015 6:23 pm
Posts: 6
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
Cattura.PNG [ 14.75 KiB | Viewed 6259 times ]
Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 02, 2015 8:01 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
Hi!

Please look at this thread:
viewtopic.php?p=8827#p8827

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 02, 2015 11:19 am 
Offline

Joined: Thu Mar 26, 2015 6:23 pm
Posts: 6
Thanks!

I solved writing the rows containing data with no borders alternate to an empty row with height = ".02cm", Heightrule = AtLeast and only the top borders of each cell.

At the moment it seems to work good!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 77 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group