Right to left issues

Hello.

I'm having problems using the document builder with right-to-left text.

The problem is that the text has both hebrew (right-to-left) and english text.

The export using the Bidi values creates the document with reverse english text (for example: NET.ASP) and exporting without Bidi create the document with reverse hebrew text.

What can I do about this issue?

The code using Bidi:

_data = "עובדת מזה 6 שנים בחברת \"יעל תוכנה\", כשבארבע השנים האחרונות עובדת על פרויקט הקמת מערכת אינטראנט לניהול תביעות במכון מור. יש לה ניסיון רב בכל שלבי הפיתוח, מאפיון ועד עליית הפרויקט לאוויר, עיצוב ופיתוח מערכת בטכנולוגיית ASP.NET בשפת C# מול בסיס נתונים SQL Serve ופיתוח תשתיות לניהול תהליכים, יצירת Custom & User Controls וניסיון נרחב בשימוש באובייקטי ADO.NET לעבודה מול בסיס הנתונים.כמו כן עבדה עם Web Services, Stored Procedures, Java ו- Servlets בעבר.";

Builder.Write(_data);

NodeCollection paragraphs =Builder.Document.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph paragraph in paragraphs)

{

paragraph.ParagraphFormat.Bidi = true;

}

NodeCollection runs = Builder.Document.GetChildNodes(NodeType.Run, true);

foreach (Run run in runs)

{

run.Font.Bidi = true;

}

The problem is that MS Word cannot ensure correct rendering of runs which have mixed RTL and LTR characters inside. If we paste this text to MS Word we will see that MS Word cuts this run into separate words and literals and inserts each one separately with correct setting of Bidi attribute. That can be seen using our DocumentExplorer source code demo project or by saving document in WordML format and looking at resulting xml.

DocumentBuilder does not have such ability yet so you need to do this manually for the time being. Fo example:

builder.ParagraphFormat.Bidi = true;

builder.Font.Bidi = true;

builder.Write("עובדת מזה 6 שנים בחברת \"יעל תוכנה\", כשבארבע השנים האחרונות עובדת על פרויקט הקמת מערכת אינטראנט לניהול תביעות במכון מור. יש לה ניסיון רב בכל שלבי הפיתוח, מאפיון ועד עליית הפרויקט לאוויר, עיצוב ופיתוח מערכת בטכנולוגיית");

builder.Font.Bidi = false;

builder.Write(" ASP.NET ");

builder.Font.Bidi = true;

builder.Write("בשפת");

builder.Font.Bidi = false;

builder.Write(" C# ");

builder.Font.Bidi = true;

builder.Write("מול בסיס נתונים");

builder.Font.Bidi = false;

builder.Write(" SQL Server ");

builder.Font.Bidi = true;

builder.Write("ופיתוח תשתיות לניהול תהליכים, יצירת");

builder.Font.Bidi = false;

builder.Write(" Custom & User Controls ");

builder.Font.Bidi = true;

builder.Write("וניסיון נרחב בשימוש באובייקטי");

builder.Font.Bidi = false;

builder.Write(" ADO.NET ");

builder.Font.Bidi = true;

builder.Write("לעבודה מול בסיס הנתונים.כמו כן עבדה עם");

builder.Font.Bidi = false;

builder.Write(" Web Services, Stored Procedures, Java ");

builder.Font.Bidi = true;

builder.Write("ו");

builder.Font.Bidi = false;

builder.Write("- Servlets ");

builder.Font.Bidi = true;

builder.Write("בעבר");

builder.Font.Bidi = false;

builder.Write(".");

Note that Bidi attributes are set using DocumentBuiilder. Hence, setting Bidi attributes iterating through all runs and paragraphs is not necessary.

I have logged this problem to DTTS as issue #1131. We will probably add the ability to cut mixed runs inside DocumentBuilder.Write method some time later.

Best regards,

I currently used this solution, similair to what you suggested:

public void WriteHebrewEnlish(string text, bool newLine)

{

bool hebrew = true;

char[] values = text.ToCharArray();

for (int charIndex = 0; charIndex < values.Length; charIndex++)

{

char ch = values[charIndex];

if (ch == ' ')

{

if (charIndex + 1 < values.Length &&

values[charIndex + 1] >= 'א' && values[charIndex + 1] <= 'ת')

{

hebrew = true;

}

}

if (ch >= 'א' && ch <= 'ת')

hebrew = true;

else if (char.IsLetterOrDigit(ch))

hebrew = false;

Builder.Font.Bidi = hebrew;

Builder.Font.SizeBi = Builder.Font.Size;

Builder.Write(ch.ToString());

}

if (newLine)

Builder.Writeln("");

}

This is due to the fact that I don't 'know' what will be text and I need to create ducments dynamiclly.

Please work on a better solution.

Thanks.

Yes, we are going to add something like this inside DocumentBuilder.Write method. Maybe in the next hotfix. Thanks for drawing our attention to this problem.

Best regards,

Sorry this is not coming out in the next release, I moved it into into the future plans.