在iTextSharp中反转从右到左(双向)语言的字符串 [英] Reversing Strings in Right To Left (BiDirectional) Languages in iTextSharp

查看:164
本文介绍了在iTextSharp中反转从右到左(双向)语言的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iTextSharp(C#iText端口)从text / html创建pdf。我的大多数文本都是希伯来语,一种从右到左的语言。

I'm using iTextSharp( C# iText port) to create pdfs from text/html. Most of my text is in Hebrew, a Right-To-Left language.

我的问题是PDF显示反向RTL语言,所以我需要在一种只能反转RTL文本而不用英语反转任何数字或文本的方法。
据我所知,fribidi允许在linux上执行此操作,但我找不到针对此问题的任何解决方案。

My problem is that PDFs show RTL langauge in reverse, so I need to reverse my strings in a way that would only reverse the RTL text without reversing any numbers or text in English. It is my understanding that fribidi allows doing that on linux, but I couldn't find any solutions for this problem for Windows.

我欢迎任何建议,包括自动执行此操作的iTextSharp的替代方法(如果存在)。

I would welcome any suggestions, including an alternative to iTextSharp that would do this automatically (if one exists).

推荐答案

通过正确使用iTextSharp显示RTL文本:

To show RTL texts by using iTextSharp correctly:


  • 您需要将字体的编码设置为 BaseFont.IDENTITY_H

  • 然后你必须使用支持 RunDirection 的容器元素,例如 PdfPCell ColumnText 等,现在你可以设置他们的元素.RunDirection = PdfWriter.RUN_DIRECTION_RTL ;

  • You need to set the font's encoding to BaseFont.IDENTITY_H
  • Then you have to use container elements which support RunDirection, such as PdfPCell, ColumnText, etc. and now you can set their element.RunDirection = PdfWriter.RUN_DIRECTION_RTL;

这篇关于在iTextSharp中反转从右到左(双向)语言的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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