Enum DocumentDirection

Enum DocumentDirection

Namespace: Aspose.Words.Loading
Assembly: Aspose.Words.dll (25.12.0)

Allows to specify the direction to flow the text in a document.

public enum DocumentDirection

Fields

Auto = 2

Auto-detect direction.

When this option is selected and text contains characters belonging to RTL scripts, the document direction will be set automatically to RTL.

LeftToRight = 0

Left to right direction.

RightToLeft = 1

Right to left direction.

Examples

Shows how to detect plaintext document text direction.

// Create a "TxtLoadOptions" object, which we can pass to a document's constructor
                                                                 // to modify how we load a plaintext document.
                                                                 TxtLoadOptions loadOptions = new TxtLoadOptions();

                                                                 // Set the "DocumentDirection" property to "DocumentDirection.Auto" automatically detects
                                                                 // the direction of every paragraph of text that Aspose.Words loads from plaintext.
                                                                 // Each paragraph's "Bidi" property will store its direction.
                                                                 loadOptions.DocumentDirection = DocumentDirection.Auto;

                                                                 // Detect Hebrew text as right-to-left.
                                                                 Document doc = new Document(MyDir + "Hebrew text.txt", loadOptions);

                                                                 Assert.That(doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Bidi, Is.True);

                                                                 // Detect English text as right-to-left.
                                                                 doc = new Document(MyDir + "English text.txt", loadOptions);

                                                                 Assert.That(doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Bidi, Is.False);
 English