Merge branch 'master' of https://github.com/sailingnn/python-docx-template into sailingnn-master

This commit is contained in:
Eric Lapouyade 2022-08-04 09:46:44 +02:00
commit ea987f9e38
3 changed files with 19 additions and 1 deletions

View File

@ -79,7 +79,7 @@ class RichText(object):
if strike:
prop += u'<w:strike/>'
if font:
prop += (u'<w:rFonts w:ascii="{font}" w:hAnsi="{font}" w:cs="{font}"/>'
prop += (u'<w:rFonts w:ascii="{font}" w:hAnsi="{font}" w:cs="{font}" w:eastAsia="{font}"/>'
.format(font=font))
xml = u'<w:r>'

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
'''
Created : 2022-08-03
@author: Dongfang Song
'''
from docxtpl import DocxTemplate, RichText
tpl=DocxTemplate('templates/richtext_eastAsia_tpl.docx')
rt = RichText('测试TEST', font = 'Microsoft YaHei')
ch = RichText('测试TEST', font = '微软雅黑')
sun = RichText('测试TEST', font = 'SimSun')
context = {
'example' : rt,
'Chinese' : ch,
'simsun' : sun,
}
tpl.render(context)
tpl.save('output/richtext_eastAsia.docx')

Binary file not shown.