elapouya / python-docx-template

Use a docx as a jinja2 template
GNU Lesser General Public License v2.1
1.92k stars 378 forks source link

In MacOS enviroment,the font is in correct!help #536

Open AndyChenrun opened 2 months ago

AndyChenrun commented 2 months ago

Describe your problem

In the MacOS environment, use the docxtpl {{}} method to insert text into the template. Unfortunately, the font is incorrect. How to solve it?

More details about your problem

1.Open template.doc

  1. Write data through render method
  2. Save the file
AndyChenrun commented 2 months ago

I had tried like below: from docx import Document

document = Document("example.docx") for run in document.runs: run.font.name = "Arial" run.font.size = Pt(12) run.font.color.rgb = RGBColor(0x42, 0x24, 0xE9)

document.save("modified_example.docx")

this code does not work fine.