下面的代码呈现以下 PDF:Link to PDF on Google Docs。(我不被允许在这篇文章中粘贴图片)
每首歌曲都有歌曲标题和和弦进行。我正在寻找的是为每首歌曲/和弦单元格设置一行。在示例中,我在代码中对最后一首歌曲进行了硬编码,以显示它应该呈现的样子。每首歌都应该有自己的表格行。我已经研究了几个小时,但无法弄清楚......希望这是一个简单的解决方案,我只是错过了一些非常明显的东西。
谢谢你的帮助。
//Fired when SET header clicked to generate PDF
$scope.openPDF = function (SetName, setSongs) {
songTitles = [];
songChords = [];
angular.forEach(setSongs, function(value, key) {
songTitles.push({ text: value.Title, style: 'tableHeader'});
songChords.push({ text: value.Chords, style: 'tableHeader'});
});
var docDefinition =
{
pageOrientation: 'landscape',
content: [
{ text: 'SET 01', style: 'firstLine'},
{ text: SetName, style: 'secondLine' },
{
table:
{
headerRows: 0,
body:
[
[songTitles, songChords],['American Girl', 'D - E - G - A']
]
}
}
],
styles: {
firstLine: {
fontSize: 32,
bold: true,
alignment: 'center'
},
secondLine: {
fontSize: 15,
bold: true,
alignment: 'center'
},
}
};//End docDefinition
//Generate PDF
pdfMake.createPdf(docDefinition).open();
}; //END Function