I m creating an Advanced PDF in ARABIC. its a kind of letter with only Arabic text. It is not getting justify. i tried using style="text-align: justify; text-justify: inter-word;"
in <td>
as well as in <span>
but still no use.
Can anyone give me an idea if it is possible to justify arabic or not? My script chunk:
<?xml version="1.0"?>
<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<!-- <pdf dir="rtl" lang="ar"> -->
<pdf>
<head>
<!-- arabic Font -->
<link name="majalla" type="font" subtype="opentype"
src="https://5486702.app.netsuite.com/core/media/media.nl?id=8627&c=5486702&h=3e47c429eda24f454f39&_xt=.ttf"
bytes="6" />
<style type="text/css">
body {
font-family: majalla;
font-size: 18pt;
}
</style>
</head>
<body font-famly="ariel" header="nlheader" header-height="14%" footer="nlfooter" footer-height="20pt"
padding="0.5in 0.7in 0.5in 0.7in" size="Letter">
<table width="100%" table-layout="fixed">
<tr margin-top="10px">
<td align="right" lang="Ar">
<#if record.custbody7?has_content>
<p align="right"><span align="right" style="text-align: justify; text-justify: inter-word;">${record.custbody7}</span>
<#else>
<p align="right" style="text-indent: 35px;"><span align="right">أفيدكم بأنه لا مانع لدينا من قيامكم
بتنفيذ المشروع أعلاه وذلك لمدة </span>
<span align="right" style="text-align: justify; text-justify: inter-word;">(
${record.custbody_duration?string?replace('0','٠')?replace('1','١')?replace('2','٢')?replace('3','٣')?replace('4','٤')?replace('5','٥')?replace('6','٦')?replace('7','٧')?replace('8','٨')?replace('9','٩')}
)</span> <!-- duration -->
<span align="right" style="text-align: justify; text-justify: inter-word;"> تبدأ من تاريخ </span>
<span align="right" style="text-align: justify; text-justify: inter-word;">${record.custbody_start_date?string?replace('0','٠')?replace('1','١')?replace('2','٢')?replace('3','٣')?replace('4','٤')?replace('5','٥')?replace('6','٦')?replace('7','٧')?replace('8','٨')?replace('9','٩')}
م ، </span> <!-- start date -->
</#if>
<span align="right" style="text-align: justify; text-justify: inter-word;">ومن ثم ترفع المطالبات للإدارة المالية بتقديم جميع المستندات المؤيدة للصرف علًما بأن أصل
هذا التعميد لدى الإدارة المالية في مكتب برنامج خدمة ضيوف الرحمن. </span>
</p>
</td>
</tr>
</table>
</body>
</pdf>
At serveral places you are using <span align="right">
. There are three problems here:
1.) span
is an inline element – it's useless to use text-alignment in an inline element. Use div
instead of span
. That's a block element, and its default width is the full width of its parent element, so text alignment will have an effect.
2.) align="right"
is not a valid HTML attribute. If you want to add the alignment to an element like a div
directly, you have to use <div style="text-align: right;">
. Or (better) you apply a class to the DIV and set up a CSS rule for that class which contains the desired text-alignment. If you want your text justified, use <div style="text-align: justify;">
instead.
3.) For languages which are written from right to left, you not only use right alignment, but also add a text direction parameter like direction: rtl;
("right to left"), so alltogether that would be <div style="text-align: justify; direction: rtl;">
, or (better) a CSS rule for a class containing those settings which you apply to your HTML tags.