Right-to-Left Text

With GemBox.Document, you can work with documents that contain bidirectional texts. This includes languages that use right-to-left scripts such as Arabic, Persian, Urdu, Hebrew and Yiddish.

Besides read and write support for Word documents with bidirectional text, GemBox.Document supports rendering such text to PDF, XPS and image formats.

You can customize the direction of document elements by using the following properties:

The following example shows how you can convert a document with bidirectional text to PDF or other file format.

Word document with right-to-left text converted to PDF file
Screenshot of converted PDF with right-to-left text
Upload your file (Drag file here)
using GemBox.Document;
using GemBox.Document.Tables;

class Program
    static void Main()
        // If using Professional version, put your serial key below.

        var document = DocumentModel.Load("%InputFileName%");

        // Show line numbers on the right side of the page
        var pageSetup = document.Sections[0].PageSetup;
        pageSetup.LineNumberRestartSetting = LineNumberRestartSetting.Continuous;
        pageSetup.RightToLeft = true;

        // Create a new right-to-left paragraph
        var paragraph = new Paragraph(document);
        paragraph.ParagraphFormat.RightToLeft = true;
        paragraph.Inlines.Add(new Run(document, "أخذ عن موالية الإمتعاض"));

        // Create a right-to-left table
        var table = new Table(document);
        table.TableFormat.RightToLeft = true;
        table.TableFormat.PreferredWidth = new TableWidth(100, TableWidthUnit.Percentage);
        var row = new TableRow(document);

        var firstCellPara = new Paragraph(document, "של תיבת תרומה מלא");
        firstCellPara.ParagraphFormat.RightToLeft = true;
        row.Cells.Add(new TableCell(document, firstCellPara));

        var secondCellPara = new Paragraph(document, "200");
        row.Cells.Add(new TableCell(document, secondCellPara));


Imports GemBox.Document
Imports GemBox.Document.Tables

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.

        Dim document = DocumentModel.Load("%InputFileName%")

        ' Show line numbers on the right side of the page
        Dim pageSetup = document.Sections(0).PageSetup
        pageSetup.RightToLeft = true
        pageSetup.LineNumberRestartSetting = LineNumberRestartSetting.Continuous

        ' Create a new right-to-left paragraph
        Dim paragraph = new Paragraph(document)
        paragraph.ParagraphFormat.RightToLeft = true
        paragraph.Inlines.Add(new Run(document, "أخذ عن موالية الإمتعاض"))

        ' Create a right-to-left table
        Dim table = new Table(document)
        table.TableFormat.RightToLeft = true
        table.TableFormat.PreferredWidth = new TableWidth(100, TableWidthUnit.Percentage)
        Dim row = new TableRow(document)

        Dim firstCellPara = new Paragraph(document, "של תיבת תרומה מלא")
        firstCellPara.ParagraphFormat.RightToLeft = true
        row.Cells.Add(new TableCell(document, firstCellPara))

        Dim secondCellPara = new Paragraph(document, "200")
        row.Cells.Add(new TableCell(document, secondCellPara))


    End Sub

End Module

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Document yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.