Free Support Forum - aspose.com

Problems with Margins Not Being Applied

We recently upgraded from v4.0.0.0 to v4.1.0.0 to take advantage of some other fixes but there appears to be several BIG bugs in the new release. The main one that seems to be causing the most grief for us is that paragraph margins don’t seem to be getting applied! I’ve developed a test subroutine to demonstrate this for your review (based on a document I found in the Knowledge Base). In addition, I’ve attached the generated PDFs using the exact same code but referencing v4.0.0.0 and v4.1.0.0 so you can see the difference. My take is that this a big enough breaking change that a hotfix should be issued once it’s fixed.

Public Sub Test()
Dim pdf1 As New Pdf()
’ Create a Pdf section object
Dim sec As Aspose.Pdf.Section = pdf1.Sections.Add()

'Set the page border of the section using BorderInfo object
sec.PageInfo.PageBorder = New BorderInfo(BorderSide.All, 0.2)

'Create MarginInfo object and set its left, bottom, right and top margins
Dim margin As New MarginInfo()
margin.Top = 5.0F
margin.Left = 5.0F
margin.Right = 5.0F
margin.Bottom = 5.0F

Dim cellPadding As New MarginInfo()
cellPadding.Top = 15.0F
cellPadding.Left = 15.0F
cellPadding.Right = 15.0F
cellPadding.Bottom = 15.0F

'Instantiate a table object
Dim tab1 As New Aspose.Pdf.Table()
'Add the table in paragraphs collection of the desired section
sec.Paragraphs.Add(tab1)

'Set with column widths of the table
tab1.ColumnWidths = “230”

'Set default cell border using BorderInfo object
tab1.DefaultCellBorder = New BorderInfo(CInt(BorderSide.All), 1.0F)
'Set table border using another customized BorderInfo object
tab1.Border = New BorderInfo(CInt(BorderSide.All), 1.0F)
'Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin
tab1.Margin.Top = -50 'not getting applied

For i As Integer = 1 To 2
'Create rows in the table and then cells in the rows
Dim row1 As Aspose.Pdf.Row = tab1.Rows.Add()
’ create inner table to be displayed in the outer table

Dim innertable As New Aspose.Pdf.Table()
'Set default cell border using BorderInfo object
innertable.DefaultCellBorder = New BorderInfo(CInt(BorderSide.All), 1.0F, New Aspose.Pdf.Color(“Blue”))
’ set the column width of the inner table
innertable.ColumnWidths = “100 100”
innertable.DefaultCellPadding = cellPadding
’ set the background color for inner table
innertable.BackgroundColor = New Aspose.Pdf.Color(“Silver”)
’ set the foreground color for the text of innertable
innertable.DefaultCellTextInfo.Color = New Aspose.Pdf.Color(“White”)

’ add the First column in 1nd row of inner table
innertable.Rows.Add().Cells.Add(“Column (0, 0)”)
’ add the 2nd column in 1st row of inner table
innertable.Rows(0).Cells.Add(“Column (0, 1)”)
’ add the First column in 2nd row of inner table
innertable.Rows.Add().Cells.Add(“Column (1, 0)”)
’ add the 2nd column in 2nd row of inner table
innertable.Rows(1).Cells.Add(“Column (1, 1)”)

’ add the inner table to paragraphs collection of row of outer table
row1.Cells.Add().Paragraphs.Add(innertable)
Next

'Instantiate a table object
Dim tab2 As New Aspose.Pdf.Table()
'Add the table in paragraphs collection of the desired section
sec.Paragraphs.Add(tab2)

'Set with column widths of the table
tab2.ColumnWidths = “230”

'Set default cell border using BorderInfo object
tab2.DefaultCellBorder = New BorderInfo(CInt(BorderSide.All), 1.0F)
'Set table border using another customized BorderInfo object
tab2.Border = New BorderInfo(CInt(BorderSide.All), 1.0F)
'Set the default cell padding to the MarginInfo object
tab2.DefaultCellPadding = margin
tab2.Margin.Top = 75 'not getting applied either!

For i As Integer = 1 To 2
'Create rows in the table and then cells in the rows
Dim row2 As Aspose.Pdf.Row = tab2.Rows.Add()
’ create inner table to be displayed in the outer table

Dim innertable As New Aspose.Pdf.Table()
'Set default cell border using BorderInfo object
innertable.DefaultCellBorder = New BorderInfo(CInt(BorderSide.All), 1.0F, New Aspose.Pdf.Color(“Blue”))
’ set the column width of the inner table
innertable.ColumnWidths = “100 100”
innertable.DefaultCellPadding = cellPadding
’ set the background color for inner table
innertable.BackgroundColor = New Aspose.Pdf.Color(“Yellow”)
’ set the foreground color for the text of innertable
innertable.DefaultCellTextInfo.Color = New Aspose.Pdf.Color(“Black”)

’ add the First column in 1nd row of inner table
innertable.Rows.Add().Cells.Add(“Column (0, 0)”)
’ add the 2nd column in 1st row of inner table
innertable.Rows(0).Cells.Add(“Column (0, 1)”)
’ add the First column in 2nd row of inner table
innertable.Rows.Add().Cells.Add(“Column (1, 0)”)
’ add the 2nd column in 2nd row of inner table
innertable.Rows(1).Cells.Add(“Column (1, 1)”)

’ add the inner table to paragraphs collection of row of outer table
row2.Cells.Add().Paragraphs.Add(innertable)
Next

'pdf1.Bookmarks.Add(tocbookmark);
pdf1.Save(“c:/Table_InsideTable.pdf”)
End Sub

Notice how the Margin.Top values for the tables are not getting applied in v4.1.0.0?

Hi,

Thank you for considering Aspose.

I have reproduced the error and it has been logged as PDFNET-10727 in our issue tracking system. We will try to resolve the issue before next hotfix (next week).

Thanks,

Just checking in, as it’s been over three weeks now. Any word on when this issue will be fixed?

Hi,

I’m pleased to inform you that the issue has been resolved. The hotfix will be shared with in this week. Please be patient and spare us little time.

The issues you have found earlier (filed as 10727) have been fixed in this update.


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