如何在 aspose.word 中为 C# .Net 更改目录的方向

how to change direction of TOC in aspose.word for C# .Net

我通过 Aspose.Word 创建了一个 table 的内容,但我的文档方向是从右到左,我想将方向更改为 rtl。

请使用以下代码示例创建从右到左方向的 table 内容。希望这对你有帮助。

Document doc = new Document(MyDir + "in.docx");

// Create a document builder to insert content with into document.
DocumentBuilder builder = new DocumentBuilder(doc);

// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia.

builder.Font.LocaleIdBi = 1025;
builder.ParagraphFormat.Bidi = true;
builder.Font.NameBi = "Heading 1";
builder.Font.SizeBi = 10;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.Font.Bidi = true;

doc.Styles[StyleIdentifier.Toc1].ParagraphFormat.Bidi = true;
doc.Styles[StyleIdentifier.Toc1].Font.Bidi = true;

builder.InsertTableOfContents("\o \"1-3\" \h \z \u");
builder.Writeln();

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("مرحبا هناك ما هو اسمك وماذا تفعل في هذا");

// Call the method below to update the TOC.
doc.UpdateFields();
doc.Save(MyDir + "output.docx");

我在 Aspose 工作,担任开发人员推广员。