我是jspdf / jspdf-Autotable的新手,

我想动态对齐我的列,如果它是右边的数字,如果它是左边的文本 . 我一直在查看示例和文档,但我找不到做类似事情的选项 .

我也尝试过以下操作,但它不起作用:

function pdf(obj, table_id) {
var doc = new jsPDF('l', 'mm', "a4");
var res = doc.autoTableHtmlToJson(document.getElementById("table_id"));

doc.autoTableSetDefaults({
        styles: {
            fontSize: 7,
           overflow: 'linebreak',
           tableWidth: 'auto',
           columnWidth: 'auto'

        },

        margin: {top: 100, left: 5},

        headerStyles: {fillColor: [38, 62, 144]}
     });

var header = function(data) {         
        doc.setFontSize(12);
        doc.setTextColor(40);
        doc.setFontStyle('bold');
        doc.text("Title", data.settings.margin.left, 15);
        doc.text("text footer", data.settings.margin.left, 24);
     };

     var footer = function(data) {
        var currentpage = 0;

        if (currentpage >= data.cursor.y) {
            data.pageCount++;
        }

        var str = "Page " + data.pageCount;

        if (typeof doc.putTotalPages === 'function') {
            str = str; //+ " de " + data.pageCount;
         }

        doc.setFontSize(9);
        doc.text(str, data.settings.margin.left, doc.internal.pageSize.height - 10);
        doc.text("Created by Company. "+date, data.settings.margin.right + 190, doc.internal.pageSize.height - 10);
     };

     var options = {
       beforePageContent: header,
       afterPageContent: footer,
       margin: {
        top: 30
       }
     };

doc.autoTable(res.columns, res.data, options,{
 drawCell: function (cell, data) {
            texto = "texts";                
             /*This works but when there are no other styles*/

             if ((text.match(/[a-z]/i))){ 
                    cell.styles.halign = 'left';
                    console.log("RIGHT");
             }
             if (!(text.match(/[a-z]/i))){
                    cell.styles.halign = 'left';//
                    console.log("LEFT");
             }

   }
 });

doc.save("FILE.pdf"); 
}