如何通过 aspsoe.word for c#.Net 将段落的方向和对齐方式更改为 rtl

how to change direction and alignment of paragraph to rtl by aspsoe.word for c#.Net

我将段落的对齐方式更改为右对齐,但是当我将段落的方向更改为从右到左(通过 builder.ParagraphFormat.Bidi= true)时,我的对齐方式更改为左对齐。

builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.Font.Bidi=true;
builder.Font.LocaleIdBi = 1025;
builder.ParagraphFormat.Bidi= true;

尝试将对齐移动到 Bidi 语句之后?

我变了

builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;

builder.ParagraphFormat.Alignment = ParagraphAlignment.Left

并工作。

请尝试使用以下代码:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Signal to Microsoft Word that this run of text contains right-to-left text.
builder.Font.Bidi = true;
builder.CurrentParagraph.ParagraphFormat.Bidi = true;

builder.Font.LocaleIdBi = 1025;

// Insert some Arabic text.
builder.Writeln("هذا كتاب.");

doc.Save("D:\Temp\17.11.docx");

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