Search code examples
angularjspdfjspdf-autotable

Auto table in jsPDF


How to create a black border for table in plain theme in PDF generated from jsPDF? I have tried writing in styles like

styles: {
   overflow: 'linebreak',
   border: 'solid black 1px'
}

but it does not work.


Solution

  • I found the solution.It can be given by line width and line color.

    var doc = new jspdf('p','pt','a4');
    doc.autoTable(columns, rows, { headerStyles: { lineWidth: 0.06, lineColor: [217, 216, 216] }, beforePageContent: header, margin: {top: 40}, theme: 'plain', styles: { overflow: 'linebreak', lineWidth: 0.02, lineColor: [217, 216, 216] } }); var header = function (data) { doc.setFontSize(25); doc.setTextColor(0); doc.text(this.companyname,15,15); doc.setFontStyle('normal'); }; doc.autoTableHtmlToJson(columns, rows); doc.save("file.pdf");