Aspose languages support

i need to know if aspose supports arabic language

iam trying to render an arabic sentence to word document using aspose.

المغادرة الى المطار

the sentence words will be reversed in the document

المطارالى المغادرة

aim using these two commands to render it and both they give me tha same result:

TempDoc.MailMerge.Execute(MailMergeFieldsNames, MailMergeFieldsValues)

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

builder.MoveToMergeField(MailMergFieldNames(i))

builder.InsertHtml(MailMergFieldValues(i))

the result file is attachecd to this email

thanks in advance

There are actually four settings in Word that control the layout differences for text made with left-to-right and right-to-left languages:

  1. Font.Bidi Property - when true, specifies that this run contains right-to-left text.
  2. ParagraphFormat.Bidi Property - when true, the runs and other inline objects in this paragraph are laid out right to left.
  3. RowFormat.Bidi Property - when true, the cells in this row are laid out right to left.
  4. PageSetup.Bidi Property - when true, the columns in this section are laid our from right to left.

Therefore, when you insert some right-to-left text in the document that is not inside the table and you don't have multiple columns on your page, you need to ensure that at least Font.Bidi and ParagraphFormat.Bidi are set to true for all runs and paragraphs that are inserted into the document in RTL language.

Here is an example:

DocumentBuilder builder = new DocumentBuilder(doc);

builder.ParagraphFormat.Bidi = false;

builder.Font.Bidi = true;

builder.Writeln("المغادرة الى المطار");

thanx for you replay

but my problem is deeper than this.

the report language is english but from time to time i have an arabic text to display and some time i have to render both arabic and english into same mail merg field.

the weird thing that if i copy the reversed text into a new word document the sentence will have it correct word order.

i dont care for the sentence alignment but i need it to be ordered correctly.

is thair are any property in the word file i can change to get the true order.

To handle your problem properly you need to know some basics about how MS Word stores text internally. The text chunk having the similar formatting, entered into document by sequential typing and not having line breaks in it (or any kind of breaks to be precise) is stored as run.

Run can span several symbols, a word, several words, several sentences. It can start in the middle of one word of one sentence and end in the middle of another word of another sentence. It can even be empty, i.e.containing no symbols at all.

For example, if you start typing in MS Word, then move your cursor elsewhere, then return to the end of typed text and add some more symbols - you will end up with two sequential runs of text, although they will have a same formatting.

Another example - when you type text then change font to bold and continue typing then you will also have two runs of text with different formatting.

Anytime you insert a line break in text by pressing you are starting the new paragraph. If you were in the middle of the run while doing this - then this run will be split in two - the first one will stay in the end of the old paragraph and the second will be moved to the start of the new paragraph.

RTL formatting of the run is controlled by Run.Font.Bidi property. If it is true and (important!) the font is a right-to left font then the order of symbols inside the run will be right-to left.

The order of runs inside the paragraph is controlled by Paragraph.ParagraphFormat.Bidi property. If it is true, runs will be ordered right-to-left. Otherwise, you can end up with wrong order of parts of your text, if the text comprises more than one run.

Now to the task of mailmerging mixed language text. Ideally, you should check the text you are inserting and set run and paragraph formatting Bidi property to true, if the text for the field is arabic. But what should we do if the text for the field is mixed. Fortunately, as I have mentioned before, only right-to left fonts actually change direction when Bidi property is set to true. That means you can simply check if the inserted text has at least one arabic character, and in that case set its Paragraph.ParagraphFormat.Bidi and Run.Font.Bidi properties to true. To set this properties during mailmerge process use MergeField event. It will give you full control over how and in what formatting the merge for particular field is done. I presume that arabic symbols cover a certain range of unicode values, which means you can analyze if any symbol of the text is falling into this range.

that is working Big Smile [:D]Cool [H] thanks alot.

BUT Crying [:'(] when the mail merge field is placed in table it is NOT working Crying [:'(]

please can you help me with this.

THANKS ALOT FOR YOUR HELP Geeked [8-|]

Have you tried the approach with MergeField event? If you have and it does not work then please send me your code snippet - I will add the necessary corrections.

i didn't understand hoe i can use MergeFieldEventHandler to solve my problem

please can you give me a short example

for now i run this code befor i save the result document (using this i still having a problem with text in the tables)

Dim ArabicLetters() As String = {"ا", "ب", "ت", "ث", "ج", "ح", "خ", "د", "ذ", "ر", "ز", "س", "ش", "ص", "ض", "ف", "ق", "ك", "ل", "م", "ن", "ه", "و", "ي", "ة", "ء", "ئ", "أ"}

For Sectionindex As Integer = 0 To Me._MyBooklet.Sections.Count - 1

For Childsindex As Integer = 0 To Me._MyBooklet.Sections(Sectionindex).Body.ChildNodes.Count - 1

If Me._MyBooklet.Sections(Sectionindex).Body.ChildNodes(Childsindex) IsNot Nothing Then

Select Case Me._MyBooklet.Sections(Sectionindex).Body.ChildNodes(Childsindex).NodeType

Case NodeType.Paragraph

Dim iPara As Paragraph = CType(Me._MyBooklet.Sections(Sectionindex).Body.ChildNodes(Childsindex), Paragraph)

For ParagraphChildsindex As Integer = 0 To iPara.Runs.Count - 1

For ArabicLettersIndex As Integer = 0 To ArabicLetters.Length - 1

If iPara.Runs(ParagraphChildsindex).Text.Trim.Contains(ArabicLetters(ArabicLettersIndex)) Then

iPara.Runs(ParagraphChildsindex).Font.Bidi = True

Exit For

End If

Next

Next

End Select

End If

Next

Next

thanks in advance

Yes, I see. It is because paragraphs inside tables are not immediate children of Section.Body.



The following code should solve your problem:



arabicSymbols As String = “ابتثجحخدذرزسشصضفقكلمنهويةءئأ”



’ take all paragraphs in the document

For Each paragraph As Paragraph In doc.GetChildNodes(NodeType.Paragraph, true)

’ if paragraph text contains arabic characters

If paragraph.GetText().IndexOfAny(arabicSymbols.ToCharArray()) >= 0 Then

’ then set its Bidi formatting to true

paragraph.ParagraphFormat.Bidi = True

End If

Next paragraph

’ take all runs in the document

For Each run As Run In doc.GetChildNodes(NodeType.Run, true)

’ if run text contains arabic characters

If run.Text.IndexOfAny(arabicSymbols.ToCharArray()) >= 0 Then

’ then set its Bidi formatting to true

run.Font.Bidi = True

End If

Next run

Party!!! [<:o)]

thank you this is working great

Yes [Y]