-1

I want to change Direction by Aspose.Word Or OpenXml Word (WordprocessingDocument ) (C#). method is like here:

private static void AddHtmlToDoc()
{
    var html = @"<html> <a href=""http://www.google.com/"" style=""color:#FF0000;"">Red Link</a><a href=""http://www.google.com/"" style=""color:#00FF00;"">Blue Link</a > </ html > ";
    Aspose.Words.Document docAspose = new Words.Document();
    Words.DocumentBuilder b1 = new DocumentBuilder(docAspose);
    b1.InsertHtml(html);
    docAspose.Save(dir2);
    WordprocessingDocument doc = WordprocessingDocument.Open(dir2, true);
    var documentPart = doc.MainDocumentPart.Document.Body;
       
    Console.ReadKey();
}

How can I do it?

enter image description here

amin
  • 561
  • 6
  • 18

1 Answers1

0

I found solution. for right to left direction we must use this code:

b1.CurrentParagraph.ParagraphFormat.Bidi

Unfortunately I use this code befor

b1.InsertHtml(html);

but when I used it after top line, it worked true. then The following method works:

private static void AddHtmlToDoc()
{
  var html = @"<html> <a href=""http://www.google.com/"" style=""color:#FF0000;"">Red Link</a><a href=""http://www.google.com/"" style=""color:#00FF00;"">Blue Link</a > </ html > ";
  Aspose.Words.Document docAspose = new Words.Document();
  Words.DocumentBuilder b1 = new DocumentBuilder(docAspose);
  b1.InsertHtml(html);
  b1.CurrentParagraph.ParagraphFormat.Bidi = true;
  docAspose.Save(dir2);
   
  Console.ReadKey();
}
amin
  • 561
  • 6
  • 18