File: richtext_eastAsia.py

package info (click to toggle)
python-docx-template 0.16.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,296 kB
  • sloc: python: 1,552; makefile: 164
file content (20 lines) | stat: -rw-r--r-- 506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# -*- 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='eastAsia:Microsoft YaHei')
ch = RichText('测试TEST', font='eastAsia:微软雅黑')
sun = RichText('测试TEST', font='eastAsia:SimSun')
context = {
    'example': rt,
    'Chinese': ch,
    'simsun': sun,
}

tpl.render(context)
tpl.save('output/richtext_eastAsia.docx')