Python-docx set the text direction RTL

后端 未结 1 799
长发绾君心
长发绾君心 2021-01-22 18:43

I am trying to create a docunent with RTL (Right-To-Left) text direction

def printExam():

  #get the exam questions 

  rows = db(db.exam_questions.exam == req         


        
1条回答
  •  悲&欢浪女
    2021-01-22 19:33

    No custom style has been defined on your paragraph so a default latent style is applied and this kind of style is read-only because it has no real definition in the document.

    Apply a custom style on your run or your paragraph and you will be able to customize it. For a run, you have to create character style (WD_STYLE_TYPE.CHARACTER).

    # create the document and the custom style
    document = Document()
    mystyle = document.styles.add_style('mystyle', WD_STYLE_TYPE.CHARACTER)
    ...
    ...
    # apply the custom on the run
    run.style = mystyle
    font = run.font
    font.rtl = True
    

    0 讨论(0)
提交回复
热议问题