我的尝试:
docDefinition.content.push(
{
style: 'header',
text: String(data.designer)
}
);
工作正常,但每次添加元素时我都想转到一个新页面:
docDefinition.content.push(
{
style: 'header',
text: String(data.designer),
pageBreak: 'after'
}
);
如果我尝试通过使用循环在我的节点中添加 pageBreak 它将不起作用并且我收到此错误:
Uncaught Unrecognized document structure: {"alignment":"center","_margin":null}
我尝试了几种不同的方式。甚至修改 pdfmake.js 源文件并评论一些行......不可能让它工作。
请告诉我,我可以在不检索内容数组的情况下通过用 PHP 编写它来做到这一点:-/(我找到的唯一解决方案)
谢谢
编辑 :
我发现问题出在哪里。
我在每个页面上检索具有不同内容的页脚:
var docDefinition = { footer: function(currentPage) { return { text: standnumbers[currentPage - 1], alignment: 'center' }; } };
当脚本执行最后一页并且显然是最后一个 pageBreak 时,我的数组没有更多的价值来创建最后一个空白页。
因此,通过这样做,最终创建了 pdf:
var docDefinition = { footer: function(currentPage) { if (currentPage - 1 < standnumbers.length) { return { text: standnumbers[currentPage - 1], alignment: 'center' }; } else { return { text: "END", alignment: 'center' }; } } }