I'm trying to open a word document and change its text direction to correct ones, here :
IEnumerable<DocumentFormat.OpenXml.Wordprocessing.Text> texts = doc.MainDocumentPart.Document.Body.Descendants<DocumentFormat.OpenXml.Wordprocessing.Text>();
foreach (DocumentFormat.OpenXml.Wordprocessing.Text text in texts)
{ -> Change text Direction <- }
doc.Save();
doc.Close();
doc.Dispose();
I have those texts, but how can I change their direction to right-to-left?
BiDi
class set the text direction to right-to-left:
IEnumerable<DocumentFormat.OpenXml.Wordprocessing.Text> texts = doc.MainDocumentPart.Document.Body.Descendants<DocumentFormat.OpenXml.Wordprocessing.Text>();
var run = new Run(texts);
var p = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(run);
p.ParagraphProperties = new ParagraphProperties()
{
BiDi = new BiDi(),
TextDirection = new TextDirection()
{
Val = TextDirectionValues.TopToBottomRightToLeft
}
};