问题描述
我使用 Apache FOP 2.2 导出为 PDF.我希望我的阿拉伯语文本从右到左开始.如果我将文本对齐设置为 Right,则所有字符都将位于屏幕的右端,这会导致我的 pdf 出现对齐问题.
I am using Apache FOP 2.2 to Export as PDF. I want my arabic text to start from right to left. If i give text alignment as Right all characters are going to right end of the screen which is causing alignment issue in my pdf.
代码:
<fo:block font-size="2.5mm" font-weight="bold" text-align="left" white-space="normal" margin="1.5mm"
xsl:use-attribute-sets="CustomStyles-ar">
الآن لحضورHarishالمؤتمر
</fo:block>
阿拉伯文本应该从右到左开始,而不是从左到右:
Arabic text should start from right to left instead it is starting from left to right:
推荐答案
在我们的模板中,我们设置了写作模式,如果您有项目符号列表,您可能还想设置 text-align.我们在 XSL 中有类似这样的东西,它基于传入的参数,无论我们是格式化阿拉伯语还是其他不是:
In our templates we set the writing-mode and if you have bullet lists, you may also want to set the text-align. We have something like this in XSL based on a param passed in whether we are formatting Arabic or other languages that are not:
<fo:flow flow-name="xsl-region-body">
<xsl:choose>
<xsl:when test="$direction='rtl'">
<xsl:attribute name="writing-mode">rl-tb</xsl:attribute>
<xsl:attribute name="text-align">start</xsl:attribute>
<xsl:attribute name="text-align-last">start</xsl:attribute>
<fo:bidi-override unicode-bidi="embed" direction="rtl">
<!-- content Arabic here -->
</fo:bidi-override>
</xsl:when>
<xsl:otherwise>
<!-- non RTL content -->
</xsl:otherwise>
</xsl:choose>
</fo:flow>
您甚至应该能够在较低级别对块或块容器或其他结构使用这样的东西来控制完全混合的文档.
You should be able to even use such a thing at lower levels against blocks or block-containers or other structures to control a completely mixed document.
例如,下图显示了当应用于左/右表格单元格以在左侧构建英语文档而在右侧构建阿拉伯语文档时的这一点.
For instance, the following image shows this when applied to left/right tables cells to build English document on left and Arabic on right.
这篇关于导出为 PDF 时,有没有办法从右到左开始我的阿拉伯语文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!