0

I have managed to edit the pdf export but i need to align only one column

i searched in thes datatables forum and in the pdfmake documentation but i haven't find how to do it. Please help!

My customize function is the following

customize: function ( doc ) {
  doc['footer']=(function(page, pages) {
      return {
          columns: [
          '*',
          {
          alignment: 'right',
          text: [
          { text: page.toString(), italics: true },
          ' de ',
          { text: pages.toString(), italics: true }
          ]
          }
          ],
      margin: [30, 0]
      }
  });
  var d = new Date();
  var fecha = d.toLocaleDateString('es-CL');
  var hora = d.toLocaleTimeString('es-CL');
  doc.content.splice( 1, 0, {

      columns: [
          {
              alignment: 'left',
              text: 'Comercial del Real \n Ramón Freire 471, Rancagua \n\n',
              bold: true,
          },
          {
              alignment: 'right',
              text: 'Fecha: '+fecha+'\nHora: '+hora+'     ',
              margin: [ 0, 0, 40, 0 ],
              bold: true
          }
      ]
  });

}
anguswild
  • 323
  • 4
  • 16
  • doc.content[1].table.body[0][5].alignment = 'right'; i added this and it aligns only the header. Please Help! – anguswild Jan 25 '17 at 14:10

1 Answers1

0

I found a solution on my own

var rowCount = document.getElementById("tableID").rows.length;
                for (i = 0; i < rowCount+1; i++) { 
                    doc.content[1].table.body[i][5].alignment = 'right';
                };

I really don't know if it is the best solution but it works for me

anguswild
  • 323
  • 4
  • 16