Alignment bug

I appear to have found a bug when aligning a table cell right after having aligned a paragraph. The following code produces the attached PDF. Notice that the paragraph isn't right-aligned as it should be. If you change the Table1.DefaultCellTextInfo.Alignment to Right and regenerate the PDF you'll see they both go right-aligned.

Dim license As Aspose.Pdf.License = New Aspose.Pdf.License

license.SetLicense("Aspose.Custom.lic")

Dim FontName As String = "Verdana"

Dim FontSize As Integer = 10

Dim PointsPerInch As Integer = 72

Dim ThisPdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf

ThisPdf.PageSetup.Margin.Top = 36

ThisPdf.PageSetup.Margin.Right = 36

ThisPdf.PageSetup.Margin.Bottom = 36

ThisPdf.PageSetup.Margin.Left = 36

ThisPdf.IsLandscape = False

ThisPdf.PageSetup.PageHeight = 11 * PointsPerInch

ThisPdf.PageSetup.PageWidth = 8.5 * PointsPerInch

ThisPdf.TextInfo.FontName = FontName

ThisPdf.TextInfo.FontSize = FontSize

ThisPdf.PageNumberFormat = Aspose.Pdf.PageNumberFormatType.Arab

Dim DefaultTI As Aspose.Pdf.TextInfo = New Aspose.Pdf.TextInfo

DefaultTI.FontName = FontName

DefaultTI.FontSize = FontSize

DefaultTI.Alignment = Aspose.Pdf.AlignmentType.Left

Dim Section1 As Aspose.Pdf.Section = ThisPdf.Sections.Add

Section1.TextInfo.FontName = FontName

Section1.TextInfo.FontSize = FontSize

Dim Text1 As Aspose.Pdf.Text = New Aspose.Pdf.Text("Paragraph 1 is right aligned")

Section1.Paragraphs.Add(Text1)

Text1.TextInfo = DefaultTI

Text1.Margin.Top = 0.25 * PointsPerInch

Text1.TextInfo.Alignment = Aspose.Pdf.AlignmentType.Right

Dim Table1 As Aspose.Pdf.Table = New Aspose.Pdf.Table(Section1)

Section1.Paragraphs.Add(Table1)

Table1.DefaultCellTextInfo = DefaultTI

Table1.DefaultCellTextInfo.Alignment = Aspose.Pdf.AlignmentType.Left 'This appears to override the Text1.TextInfo.Alignment line above

Table1.Margin.Top = 0.25 * PointsPerInch

Table1.ColumnWidths = "200"

Dim Table1Row1 As Aspose.Pdf.Row = Table1.Rows.Add

Dim Table1Row1Cell1 As Aspose.Pdf.Cell = Table1Row1.Cells.Add("Cell 1 is left aligned")

ThisPdf.Save("test.pdf", Aspose.Pdf.SaveType.OpenInBrowser, System.Web.HttpContext.Current.Response)

-David

Apparently I can't attach the PDF! When I click the "Add/Update" button I get "500 - Internal server error." Nice!

Hello David,

I have tested the issue and I’m able to reproduce the same problem. I have logged it in our issue tracking system as PDFNET-7126. We will investigate this issue in detail and will keep you updated on the status of a correction. We apologize for your inconvenience.

Has this been fixed yet? ?

Hello David,

Our development team is working hard to get this issues resolved. Meanwhile I’ve also contacted the team to share the ETA for the resolution of this problem.

Your patience is highly appreciated in this regard and soon you will be updated with the required information.

Hello David,

Sorry for the delay. After investigation, we find that there is something wrong in your code. Please try the following codes:

Dim license As Aspose.Pdf.License = New Aspose.Pdf.License
license.SetLicense("Aspose.Custom.lic")

Dim FontName As String = "Verdana"
Dim FontSize As Integer = 10
Dim PointsPerInch As Integer = 72
Dim ThisPdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf
ThisPdf.PageSetup.Margin.Top = 36
ThisPdf.PageSetup.Margin.Right = 36
ThisPdf.PageSetup.Margin.Bottom = 36
ThisPdf.PageSetup.Margin.Left = 36
ThisPdf.IsLandscape = False
ThisPdf.PageSetup.PageHeight = 11 * PointsPerInch
ThisPdf.PageSetup.PageWidth = 8.5 * PointsPerInch
ThisPdf.TextInfo.FontName = FontName
ThisPdf.TextInfo.FontSize = FontSize
ThisPdf.PageNumberFormat = Aspose.Pdf.PageNumberFormatType.Arab

Dim DefaultTI As Aspose.Pdf.TextInfo = New Aspose.Pdf.TextInfo
DefaultTI.FontName = FontName
DefaultTI.FontSize = FontSize
DefaultTI.Alignment = Aspose.Pdf.AlignmentType.Left

Dim Section1 As Aspose.Pdf.Section = ThisPdf.Sections.Add
Section1.TextInfo.FontName = FontName
Section1.TextInfo.FontSize = FontSize

Dim Text1 As Aspose.Pdf.Text = New Aspose.Pdf.Text("Paragraph 1 is right aligned")
Section1.Paragraphs.Add(Text1)
Text1.TextInfo = DefaultTI

Text1.Margin.Top = 0.25 * PointsPerInch
Text1.TextInfo.Alignment = Aspose.Pdf.AlignmentType.Right

Dim Table1 As Aspose.Pdf.Table = New Aspose.Pdf.Table(Section1)
Section1.Paragraphs.Add(Table1)

'We should new another TextInfo object here so that TextInfos of Text and Table won't be interfered by each other.

Dim DefaultTIForTable As Aspose.Pdf.TextInfo = DefaultTI.Clone()
'or
'Dim DefaultTIForTable As Aspose.Pdf.TextInfo = New Aspose.Pdf.TextInfo
'DefaultTIForTable.FontName = FontName
'DefaultTIForTable.FontSize = FontSize
'DefaultTIForTable.Alignment = Aspose.Pdf.AlignmentType.Left

Table1.DefaultCellTextInfo = DefaultTIForTable

Table1.DefaultCellTextInfo.Alignment = Aspose.Pdf.AlignmentType.Left
Table1.Margin.Top = 0.25 * PointsPerInch
Table1.ColumnWidths = "200"

Dim Table1Row1 As Aspose.Pdf.Row = Table1.Rows.Add
Dim Table1Row1Cell1 As Aspose.Pdf.Cell = Table1Row1.Cells.Add("Cell 1 is left aligned")
ThisPdf.Save("E:/temp/tests.pdf")

Thanks.

Best regards.