Create PDFMake table cells from angularjs .forEach loop over array -


the code below renders following pdf: link pdf on google docs. (i not allowed paste picture post)

there song titles , chord progressions each song. looking have single row each song/chords cells. in example hard coded 1 last song in code show should render like. each song should have own table row. have been @ hours , can't figure out ...hoping it's simple solution , i'm missing pretty obvious.

thanks help.

    //fired when set header clicked 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   

sorted out ...posting solution in case helps someone.

link pdf created using function below: https://drive.google.com/open?id=0b9coonovl5kor09ankrzuhppcza

all data pulled mysql database...so there table of songs various attributes (title, artist, main chord structure, etc) - table of sets contain 3 setlists per set.

    //fired when set header clicked generate pdf     $scope.openpdf = function (setlist, setsongs, setnumber) {                                songrows = [];          angular.foreach(setsongs, function(value, key) {                         songrows.push({title: value.title, chords: value.chords, whostarts: value.whostarts});                         });          var items = songrows.map(function(item) {          return [(100 + songrows.indexof(item) + 1).tostring().slice(-2) + '.', item.title, item.chords, item.whostarts];         });          var docdefinition =          {                   pageorientation: 'landscape',             content:             [                 { text: setnumber, style: 'firstline'},                 { text: setlist.eventdate + ' - ' + setlist.setname + ' @ ' + setlist.venue + '\n\n', style: 'secondline' },                                  {                       style: 'songrow',                     table:                      {                                                                          body:                        [                         [                                                        { text: '------' },                           { text: '--------------------------------------' },                           { text: '--------------------------------------' },                           { text: '--------------------------------------' },                           ]                       ].concat(items)                                              }                 }            ],             styles: {              firstline: {                fontsize: 32,                bold: true,                alignment: 'center'              },              secondline: {                fontsize: 15,                bold: true,                alignment: 'center'              },              songrow: {                fontsize: 18,                bold: true,                alignment: 'center',                                 },            }          };//end docdefinition          //generate pdf         pdfmake.createpdf(docdefinition).open();     } //end generate pdf function   

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo