如何改变C#.Net的aspose.word中的TOC方向

时间:2017-11-15 09:57:45

标签: c# .net aspose aspose.words tableofcontents

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

1 个答案:

答案 0 :(得分:3)

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

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一起担任开发者布道者。