3 回答
TA贡献1827条经验 获得超4个赞
使用自动换行模块和<br>标记来拆分行;这不是完美的,因为每个段落的顶部都有一个空白行,但这是对某些用例的简单解决方案
import textwrap
def ShowArabictext(Text):
#style_comment.alignment = TA_RIGHT
wrkText=Text
isArabic=False
isBidi=False
for c in wrkText:
cat=unicodedata.bidirectional(c)
if cat=="AL" or cat=="AN":
isArabic=True
isBidi=True
break
elif cat=="R" or cat=="RLE" or cat=="RLO":
isBidi=True
if isArabic:
#wrkText=arabic_table(wrkText)
wrkText=textwrap.wrap( wrkText,70)
wrkTexttemp=[]
l=u''
i=0
for w in wrkText:
# break each line with html markup allowed in reportlab
l=l+u'<br></br>'+arabic_rtlize.process.shape(arabic_reshaper.reshape(w ))
wrkText=l
if isBidi:
wrkText=get_display(wrkText)
return [wrkText,isArabic,isBidi]
添加回答
举报