java itext用希伯来语(rtl)和英语创建pdf [英] java itext create pdf with hebrew (rtl) and english

查看:145
本文介绍了java itext用希伯来语(rtl)和英语创建pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个包含英语和希伯来语的pdf文档,我可以通过以下方式看到希伯来字母: BaseFont unicode = BaseFont.createFont(c:/windows/fonts/arialuni.ttf, BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
但我反过来看到它们。我希望能够以rtl模式显示希伯来字符串,并且英文字符串将保持在ltr模式。

I want to create a pdf document containg english and hebrew together , I can see hebrew letters by using: BaseFont unicode = BaseFont.createFont("c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); but i see them in reverse. I want to be able to show the hebrew strings in rtl mode , and that the english strings will stay in ltr mode.

如何做到这一点?有英语和希伯来语的例子在一起吗? (或任何其他rtl语言)。

how can this be done? Is there an example of english and hebrew together? (or any other rtl languge).

感谢提前。

推荐答案

您应该能够通过ColumnText实例绘制文本并获得完整的BiDi支持。你只需要 setRunDirection PdfWriter.RUN_DIRECTION_DEFAULT 以外的其他东西。

You should be able to draw your text via an instance of ColumnText and get full BiDi support. You just need to setRunDirection to something other than PdfWriter.RUN_DIRECTION_DEFAULT.

使用具有非默认运行方向的较长版本,您可以使用 ColumnText.showTextAligned()获得相同的效果:

You might be able to get the same effect with ColumnText.showTextAligned() using the longer version with a non-default run direction:

ColumnText.showTextAligned(contentByte, Element.ALIGN_LEFT, myParagraph, x, y, rotation,
  PdfWriter.RUN_DIRECTION_LTR, 0);

这会将LTR设置为默认方向,并激活BIDI处理。在 ColumnText 中, RUN_DIRECTION_DEFAULT RUN_DIRECTION_NO_BIDI 相同。

This sets LTR as the default direction, and activates BIDI processing. Within a ColumnText, RUN_DIRECTION_DEFAULT is the same as RUN_DIRECTION_NO_BIDI.

这篇关于java itext用希伯来语(rtl)和英语创建pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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