Right to left languages

Right to left languages tutorial

RTL settings

Whenever you are certain that a document is mainly going to include "right to left" content you may instruct Javadocx to treat content by default as RTL by calling the setRTL method just after the standard call to the constructor:

The setRTL method accepts the option "bidi" and "rtl" that are set by default to enable, although you can set them explicitly to disable in case you want to override the global RTL settings.

RTL settings for specific content

Although you can refer to the API documentation for the use of the bidi and rtl options available for each method, we would like to include here some general comments that will be useful to understand the general logic of the process.

If you have already used the setRTL method, you may ignore what follows, but we guess that there may pop up plenty of situations were left to right and right to left content may be mixed in a given document so one may need to know how to switch from one to the other.

Paragraph wide properties

In order to properly format left to right paragraphs one should generally set the "bidi" optional parameter to true.

This parameter is available in the following methods:

  • addComment
  • addEndnote
  • addFootnote
  • addDateAndHour
  • addHeading
  • addmergefield
  • addPageNumber
  • addSimpleField
  • addSection
  • addText
  • modifyPageLayout

Text formatting properties

The other required formatting property "rtl" can be equally set to true in the above methods with the only difference that the addText method accepts also the rtl option (in order to format the individual runs of text that may compose the whole paragraph).

Left to right tables

The formatting of tables is equally simple, you only need to set the "bidi" option to true in the table properties parameter of the addTable method.

A simple example

We are now going to generate a simple document with some content in Hebrew and Arabic:

You can see here the final result and download the corresponding Word document: