Search code examples
c#asp.netms-wordbidirectional

Best way to write a word document in C# (Bi-Directional)


I've been struggling in the last few days, trying to write a Word document. I've tried downloading DocX by (Novacode) which was not a big success, then moved to Microsoft.Office.Interop.Word library which was better but still, not a huge success.

The problem is that I'm trying to write a Right-To-Left document, which is of course mixed with different punctuation. The moment I add punctuation the entire line is reversed.

I get many lines written from Database, write them the way they are in the document, and I can not manipulate them, unlike titles and stuff, which I can manipulate, reverse stuff and get the lines the way I want, after struggling.

I've seen some answers saying I should use a specific char which 'tells' the reading algorithm it is about to face a Right-To-Left line, but here most data is derived from database.

Has anyone faced that kind of problem and can give some advices?


Solution

  • To whoever finds it relevant, and none of the above helped, I found this answer the best for Right-To-Left documents:

    oDoc.Paragraphs.ReadingOrder = Word.WdReadingOrder.wdReadingOrderRtl;