When generating PDF documents in NetSuite using Advanced PDF templates, you might encounter challenges when displaying mixed Arabic and English text. While Arabic text should naturally render from right to left (RTL), embedding English text within Arabic strings can disrupt this flow, causing display issues. Simply applying dir="rtl" or direction: rtl; in your HTML styling might not resolve the problem.
The Issue:
The issue arises because the browser’s default rendering engine might not correctly interpret the embedded English text within the Arabic context. This can lead to the English text being displayed in the wrong order, breaking the intended reading flow.
The Solution: Using the Right-to-Left Embedding (RLE) Character
To force the correct RTL rendering, you can use the Unicode Right-to-Left Embedding (RLE) character, represented by . This character explicitly tells the browser to treat the following text as RTL, regardless of the characters’ inherent directionality.
Implementation Example:
Consider the following HTML snippet within your NetSuite Advanced PDF template:
HTML
<td align="right" class="arabic"><span> اسم: ${record.entity.custentity1000003}</span></td>
In this example:
align="right"aligns the entire table cell to the right.class="arabic"can be used to apply specific Arabic styling if needed.<span>wraps the text for better control.is the key to forcing the RTL display.${record.entity.custentity1000003}represents the NetSuite field that might contain English text.اسم:is the arabic word for name.
By prepending the entire string with , you ensure that even if ${record.entity.custentity1000003} contains English characters, the entire line will be displayed from right to left, maintaining the correct Arabic reading order.
Key Considerations:
- Scope of : The effect of
persists until a corresponding Pop Directional Formatting (PDF) character () is encountered. In this simple case, the end of the span implicitly terminates the effect. - Testing: Thoroughly test your PDF templates with various English and Arabic combinations to ensure consistent and accurate RTL rendering.
- NetSuite Advanced PDF limitations: NetSuite advanced PDF is based on older technology. So sometimes, you will have to find workarounds.
Conclusion:
Using the Unicode Right-to-Left Embedding character () is a reliable way to resolve RTL display issues when mixing Arabic and English text in NetSuite Advanced PDF templates. This technique ensures that your PDF documents are rendered correctly, providing a seamless experience for Arabic-speaking users.