1

I'm having issues with the column headers text and the row text breaking incorrectly in the middle of the word (see attached). In the attachment I would expect the "long text column" to be more squeezed which will increase the width of other columns and also increase the height of the rows.

The code I'm using is:

public exportToPDF(reportName: string, cols: any, rows: any) {
        var doc = new jsPDF('landscape');        
        doc.text(15, 40, "Report");
        var options = {            
            margin: { horizontal: 5 },
            bodyStyles: { valign: 'top' },
            styles: { overflow: 'linebreak', overflowColumns: false },
            headerStyles: {
                fillColor: [51, 122, 183],
                textColor: [255],
                halign: 'center'
            },            
            theme: 'grid'
        };
        doc.autoTable(cols, rows, options);
        doc.save('Report.pdf');
    }

Thanks for your help.longtext_attachment

Sam
  • 55
  • 2
  • 7
  • I have the same issue on my table. I have a column with large text and it expands the same way as your picture. I could solve this way: https://stackoverflow.com/questions/38787437/different-width-for-each-columns-in-jspdf-autotable/38790312#38790312 – FerA Feb 14 '18 at 12:55

2 Answers2

1

Check out the solution in this issue

Mohamed Gharib
  • 2,387
  • 1
  • 15
  • 16
0
columnWidth: 'wrap',
columnStyles:{
    0: {
        columnWidth: '100'
    },
    1: {
        columnWidth: '100'
    }, 
    2: {
        columnWidth:'100'
    },
    3: {
        columnWidth: '150'
    },
    4: {
        columnWidth: '100'
    }
}

add above lines into options object.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103