如何使用 docxtemplater 在文本后放置换行符

How to put linebreak after text with docxtemplater

我正在使用 docxtemplater 模块在 MS Word 文档中填充模板。我用过这个,但它只是将 space 添加到模板中:

var EOL = "\n";
var willBeTemplated = "Something" + EOL;

如何在这段文字后换行?

我是 docxtemplater 的创建者。

您可以使用以下代码:

const doc = new Docxtemplater(zip, {linebreaks: true});

默认情况下,docxtemplater 不考虑换行符,但使用此选项会添加它们。

https://docxtemplater.readthedocs.io/en/latest/faq.html#inserting-new-lines