[英]How can I change word office paragraph direction in aspose word by C#
我想通过 Aspose.Word 或 OpenXml Word (WordprocessingDocument) (C#) 更改方向。 方法如下:
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();
}
我该怎么做?
我找到了解决方案。 对于从右到左的方向,我们必须使用以下代码:
b1.CurrentParagraph.ParagraphFormat.Bidi
不幸的是,我之前使用过这段代码
b1.InsertHtml(html);
但是当我在顶线之后使用它时,它确实有效。 然后以下方法有效:
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();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.