Answer the question
In order to leave comments, you need to log in
How to remove fields from docx from python and at the same time keep the text entered there?
According to the zoldaten recipe, I open docx using python using the docxtemplate library , the values are decomposed from the dictionary into managed document fields (or what is it called? ContentControls?)
context = {'Договор': agreement,
'Название_подрядчика': opponent_name,
'Подрядчик_коротко': opponent_short_name,
'ГД_подрядчика': directors_name}
def make_next_doc(path_to_temple: Path,
context: dict,
output_name: str,
directory: Path):
doc = DocxTemplate(path_to_temple/"template.docx")
doc.render(context)
doc.save(directory/f"{output_name}.docx")
{{Agreement}}- instead of them, the value from agreement is substituted.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question