当导出为PDF时,有什么方法可以从右到左开始我的阿拉伯语文本 [英] is there any way to start my Arabic text from right to left when export as PDF

查看:77
本文介绍了当导出为PDF时,有什么方法可以从右到左开始我的阿拉伯语文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache FOP 2.2导出为PDF.我希望我的阿拉伯语文本从右到左开始.如果我将文本对齐方式设置为右",则所有字符都将移至屏幕的右端,这会导致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:

推荐答案

在我们的模板中,我们设置了书写模式,如果您有项目符号列表,则可能还需要设置文本对齐方式.在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时,有什么方法可以从右到左开始我的阿拉伯语文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆