AddBiDiMarks support with aspose words

Hi,

We have some RightToLeft sensitive documents containing strings like:

2 X 1

Performing document saving using MS Office dlls requires sending the flag AddBiDiMarks

Aspose words corrupts the string on save, and converts it to:

X 2 1.

What is the supported Aspose flag to mimic the Office behavior using AddBiDiMarks?

Thanks!

Shahar

Hi Shahar,

Thanks for your inquiry.

The Font.Bidi property specifies whether the contents of this run shall have right-to-left characteristics; therefore for RTL text (in case Font.Bidi returns true), you can check for the language identifier in Font.LocaleIdBi property.

The Bidi property, when on, shall not be used with strongly left-to-right text. Any behaviour under that condition is unspecified. This property, when off, shall not be used with strong right-to-left text. Any behavior under that condition is unspecified.

When the contents of this run are displayed, all characters shall be treated as complex script characters for formatting purposes. This means that BoldBi, ItalicBi, SizeBi and a corresponding font name will be used when rendering this run.

Hope this answers your query. If you still face problem, please share your document along with code here for investigation purposes.

Hi,

Thank you for your assistance.

I am still not able to produce a valid document.

Attached are:

  1. code example.
  2. problematic document - AsposeRTL\bin\heb.doc
  3. corrupt result - AsposeRTL\bin\heb.txt

Thanks,

Shahar

Hi Shahar,

Thanks for sharing the details. You are converting your document into TXT file format. Please note that Aspose.Words tries to mimic the same behavior as MS Word do. If you convert your document to txt file format by using MS Word, you will get the same output.

Moreover, please read supported features of plain text (txt) import/export from here:
https://docs.aspose.com/words/net/load-in-the-plain-text-format/
https://docs.aspose.com/words/net/save-in-the-plain-text-format/

Hi Tahir,

This is exactly my question - as stated, MS provide the “Add Bi-Directional marks” option (see link in original post).

I couldn’t find this option in TxtSaveOptions. Where is hidden?

Thanks!

Shahar

Hi Shahar,

Thanks for your inquiry. Perhaps, you are using an older version of Aspose.Words. Please use the latest version of Aspose.Words for .NET 13.3.0.1. The latest version of Aspose.Words for .NET contains the TxtSaveOptions class.

Regarding ‘Add Bi-Directional marks’, I am working over your query and will update you asap.

Hi Tahir,

Thank you - I TxtSaveOptions is available of course. As stated - I just cannot find the “Add Bidi-Directional marks” option.

Shahar

Hi Shahar,

Thanks for your inquiry. As I have shared in my earlier post that Aspose.Words tries to mimic the same behaviour as MS Word do. If you convert your document to txt file format by using MS Word, you will get the same output.

Please check my reply about ‘Bidi-Directional’ from here:
https://forum.aspose.com/t/56181

Please check the following code snippet for your kind reference.

DocumentBuilder builder = new DocumentBuilder();
builder.ParagraphFormat.Bidi = true;
builder.Font.Bidi = true;
// For the list of locale identifiers see http://www.microsoft.com/globaldev/reference/lcid-all.mspx
builder.Font.LocaleIdBi = 1037;
// Specify the font and font size to be used for the right-to-left text.
builder.Font.NameBi = "Arial";
builder.Font.SizeBi = 12;
// Specify that the right-to-left text in this run is bold and italic.
builder.Font.ItalicBi = true;
builder.Font.BoldBi = true;
builder.Writeln("The quick fox 123 jumps over the lazy dog");
builder.Document.Save(MyDir + "Font.Bidi Out.txt", SaveFormat.Text);

Hope this answers your query. Please let us know if you have any more queries.

Hi Tahir,

I am not sure I agree MS Office API and Word application provide the option to add bi-directional marks. Please see again the provided link at the first request and the attached image.

Font.Bidi and ParagraphFormat.Bidi do not seem to provide the same result (the resulting text document is still not the same as MS word’s).

Is there another setting we may use to mimic the MS Office behavior more accurately?

Thanks,

Shahar

Hi Shahar,

Thanks for sharing the detail. The MS Word’s ‘add bi-directional marks’ option is equal to Bidi property in Aspose.Words. Please see my reply from here:
https://forum.aspose.com/t/56181

To check the behaviour of Bidi Property, please execute the following code snippet at your end and check the output files (Docx/HTML/TXT).

DocumentBuilder builder = new DocumentBuilder();
// Specify the font and font size to be used for the right-to-left text.
builder.Font.NameBi = "Arial";
builder.Font.SizeBi = 12;
// For the list of locale identifiers see http://www.microsoft.com/globaldev/reference/lcid-all.mspx
builder.Font.LocaleIdBi = 1037;
for (int i = 0; i < 10; i++)
{
    if (i % 2 == 0)
    {
        builder.ParagraphFormat.Bidi = false;
        builder.Font.Bidi = false;
    }
    else
    {
        builder.ParagraphFormat.Bidi = true;
        builder.Font.Bidi = true;
    }
    builder.Writeln("The quick fox 123 jumps over the lazy dog");
}
builder.Document.Save(MyDir + "Font.Bidi Out.docx", SaveFormat.Docx);
builder.Document.Save(MyDir + "Font.Bidi Out.txt", SaveFormat.Text);
builder.Document.Save(MyDir + "Out.html", SaveFormat.Html);

Please open output txt file in notepad++ and press Ctrl + Alt + R. This action will set the text direction to Right to Left. Please see the attached images for detail. Hope this answers your query. Please let us know if you have any more queries.

Hi Tahir,

This is getting awkward…

Before I test your code, please verify it resolves the issue for the text I introduced as problematic -

original text is :2 X 1

Please note I provided a code example per your request (including source code, input document and output document). Do you think the original code will produce the correct output?

Thanks,

Shahar

Hi Shahar,

The output text document (.txt) generated via Aspose.Words contains the text “X 2 1” as you have mentioned in your first post. This is not a bug. Aspose.Words mimics the same behaviour as MS Word do.

Please convert your document into .txt file format by using MS Word and share that txt file with us for investigation purposes.

Please open this output document (generated via MS Word) in notepad and take a screen shot and attach it here for our reference. I will investigate the issue on my side and provide you more information.

Hi Tahir,

Attached are the text document and its printed image.

Please note the encoding used is Unicode.

Thanks,

Shahar

Hi Shahar,

Thanks for sharing the details. I have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-8213 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-8213) have been fixed in this .NET update and this Java update.


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