{#form}{importantFacts}{/form}
问题是字符串接管了整行
例如 :
1. This is test
2. This is a longer string so spacing is generated less
但是,如果我给更长的字符串它工作正常,基本上行为是它涵盖了整行..如何删除这些空白
如果需要显示更多代码,请告诉我。
生成文档文件
const tempFileName = `output-${new Date().getTime()}.docx`;
const content = fs.readFileSync(path.resolve(__dirname, formPath), 'binary');
const zip = new PizZip(content);
const doc = new Docxtemplater(zip, {nullGetter: () => " ", linebreaks: true});
doc.setData(data);
doc.render()
const buf = doc.getZip().generate({type: 'nodebuffer'});
fs.writeFileSync(path.resolve(__dirname, tempFileName), buf);
用于打印字符串数组的函数
function formatArrayLines(lines: string[]) {
let outputString = '';
let i = 1;
for (const line of lines) {
outputString += `${i}. ${line}\n\n`
i++;
}
return outputString;
}