Free Support Forum - aspose.com

Arabic text in segments rendered in Table.Cell

HI

am trying to render a text which contains an arabic string("simsim نور soso") in a Table.Cell.

_PdfReport = New Pdf

Dim b As New BorderInfo(BorderSide.All, 0.5)

Dim sec As Aspose.Pdf.Section = _PdfReport.Sections.Add()

Dim NewTable As Table = New Table

NewTable.ColumnWidths = "100%"

Dim row2 As Row = NewTable.Rows.Add()

Dim text As Aspose.Pdf.Text = New Aspose.Pdf.Text()

text.TextInfo.FontName = "Arial"

'Please testthe result with the two senarios and you will see the diffrent

'this is senario number one

'---------------------------------

' hte result was "simsim رون soso" (the arabic text characters was reverssed)

text.Segments.Add("simsim ")

text.Segments.Add("نور")

text.Segments.Add(" soso")

'---------------------------------

'this is senario number two

'---------------------------------

'the result is "soso نور simsim" (the words order was reversed)

'text.Segments.Add("simsim " & "نور" & " soso")

'---------------------------------

For Each Seg As Segment In text.Segments

Seg.TextInfo.IsRightToLeft = True

Seg.TextInfo.IsUnicode = True

Next

Dim Cell2 As Cell = row2.Cells.Add()

Cell2.Paragraphs.Add(text)

sec.Paragraphs.Add(NewTable)

_PdfReport.Save("simsim", SaveType.OpenInBrowser, Response)

'*****************************************

i need to render the text as i wrote it ("simsim نور soso") .

thanks.

Hi,

Thank you for considering Aspose.

As in the code you are adding three segments, so what I have done is that the arabic part I have set it to RightToLeft and for other the default LeftToRight is set. Please refer to the following code and it works for me. Please find attached Pdf output for your reference.

Dim _PdfReport As New Pdf()

Dim b As New Aspose.Pdf.BorderInfo(CInt(BorderSide.All), 0.5F)

Dim sec As Aspose.Pdf.Section = _PdfReport.Sections.Add()

Dim NewTable As New Aspose.Pdf.Table()

NewTable.ColumnWidths = "100%"

Dim row2 As Aspose.Pdf.Row = NewTable.Rows.Add()

Dim text As New Aspose.Pdf.Text()

text.TextInfo.FontName = "Arial"

Dim segment1 As Segment = text.Segments.Add()

segment1.Content = "simsim"

'text.Segments.Add("simsim ");

Dim segment2 As Segment = text.Segments.Add()

segment2.TextInfo.IsRightToLeft = True

segment2.Content = "نور"

'text.Segments.Add("نور");

Dim segment3 As Segment = text.Segments.Add()

segment3.Content = " soso"

For Each Seg As Segment In text.Segments

Seg.TextInfo.IsUnicode = True
Next

Dim Cell2 As Aspose.Pdf.Cell = row2.Cells.Add()

Cell2.Paragraphs.Add(text)

sec.Paragraphs.Add(NewTable)

_PdfReport.Save("E:/AsposeTest/LangTest.pdf")

Hope it helps.

Thanks.