java itext create pdf with hebrew (rtl) and english

和自甴很熟 提交于 2019-12-01 04:55:03

问题


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.

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

Thank's In Advance.


回答1:


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.

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);

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.



来源:https://stackoverflow.com/questions/5855078/java-itext-create-pdf-with-hebrew-rtl-and-english

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!