title: Building table dynamically with PDFMake
body: <p>I'm working with <a href="http://pdfmake.org" rel="noreferrer">pdfmake</a> to generate pdf with javascript. I'm trying to build a table dynamically but not works ,this my attempt</p>
  
  <pre class="lang-js prettyprint-override"><code>$.ajax({
      type: "POST",
      url: myURL,
      success:function(data){
          /* data has a format like :
           *[{"peaje":"Peaje 1","ruta":"Ruta 1","fechaCruce":"2014-10-18","hora":"15:42","valor":"5000"},{"peaje":"Peaje 1","ruta":"Ruta 1","fechaCruce":"2014-10-18","hora":"14:21","valor":"7000"},{"peaje":"Peaje 1","ruta":"Ruta 1","fechaCruce":"2014-09-19","hora":"11:58","valor":"17000"}]
           */
          var peajes = JSON.parse( data );
          var body = [];
          var titulos = new Array( 'PEAJE', 'RUTA', 'FECHA CRUCE', 'HORA', 'VALOR' );
          body.push( titulos );
          for (key in peajes)
          {
              if (peajes.hasOwnProperty(key))
              {
                  var peaje = peajes[key];
                  var fila = new Array();
                  fila.push( peaje.peaje.toString() );
                  fila.push( peaje.ruta.toString()  );
                  fila.push( peaje.fechaCruce.toString() );
                  fila.push( peaje.hora.toString()  );
                  fila.push( peaje.valor.toString() );
                  body.push(fila);
              }
          }
          console.log( body );
          var docDefinition = {
              content: [
              {
                  table: {
                     headerRows: 1,
                     widths: [ '*', 'auto', 100, '*' ],
                     body: body
                  }
              }]
          };//end docDefinition
          pdfMake.createPdf(docDefinition).open();
      }//end success
    });
  </code></pre>
  
  <p>This is the example of the library <a href="http://pdfmake.org/#/gettingstarted" rel="noreferrer">http://pdfmake.org/#/gettingstarted</a></p>
  
  <p>I don't know what am I doing wrong? </p>