1

yes i know many questions about this issue exists but i couldn't make any of them work.

i have python 3.7 and python-docx 0.8.11. i have tried many solutions including this one

from docx import Document, enum
document = Document()
mystyle = document.styles.add_style('mystyle', enum.style.WD_STYLE_TYPE.CHARACTER)
run = document.add_paragraph().add_run(text)
run.style = mystyle
font = run.font
font.rtl = True
document.save('test.docx')

also

from docx import Document, enum
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT

doc = Document()

rtlstyle = doc.styles.add_style('rtl', enum.style.WD_STYLE_TYPE.PARAGRAPH)
rtlstyle.font.rtl = True
p = doc.add_paragraph(text)
p.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
p.style = rtlstyle
doc.save('test.docx')

nothing worked so far

user
  • 11
  • 2
  • `i couldn't make any of them work` how so? error? not rtl? any difference between the two solutions provided? expected vs actutal – depperm Apr 06 '22 at 12:23
  • no errors it just writes it left to right – user Apr 06 '22 at 12:50
  • no difference between the two that i could see except that in one of the solutions the alignment is to the right – user Apr 06 '22 at 12:52

1 Answers1

-1

see this : https://stackoverflow.com/posts/73133074/revisions

also as mensiond here put this before your text: u'\u202B' + "your text"

or u'\u202E' if didn't work

Abd_Allah
  • 1
  • 1