Romelou Striga
Romelou Striga

Reputation: 96

Can't add font for jsPDF autotable header

I am using jspdf autotable in order to get special characters in the exported PDF files and I used a custom font from "styles" which is correctly applied to table body, but not applied for headers through "headerStyles". Any help Please??? here is the code I wrote, thanks in advance.

$('#PDFLINK').live('click', function () {

var summary = jsPDF('p', 'pt', 'a4');

            var imglogo = $("html #container header #Logo a img").prop('src');
            summary.addImage(imglogo, 'png', 425, 15);
            summary.setProperties({ title: ' Report' });
            summary.addFileToVFS('majalla.ttf', 'AAEAAA......GA==');

            summary.addFont('majalla.ttf', 'majalla', 'normal', 'Identity-H');

            summary.setFont('majalla'); // set font




            var columns = [
                { title: 'First', ', dataKey: 'First' },
                { title: 'Second', dataKey: 'Second' },
                { title: 'Third', dataKey: 'Third' }
            ];

            var rows = $("tbody tr", $("#earnings ")).map(function () {
                return {
                    First: $("td:eq(0)", this).text(),
                    Second: $("td:eq(1)", this).text(),
                    Third: $("td:eq(2)", this).text()
                };
            }).get();



            summary.setFontSize(10);

            summary.autoTable(columns, rows, {
                styles: {
                    fontSize: 12,
                    font: 'majalla'
                },
                columnStyles: {
                    fontSize: 12,
                    font: 'majalla'
                },
               headerStyles: {
                    font: 'majalla'
                },
               margin: { top: 60 },

                addPageContent: function (data) {
                    summary.text(' Report', 40, 30);

                }
            });


            summary.output('dataurlnewwindow');


});

Upvotes: 2

Views: 3964

Answers (1)

Romelou Striga
Romelou Striga

Reputation: 96

the issue is fixed, please change the headerstyles to

headerStyles: { fontStyle: 'majalla' },

Upvotes: 2

Related Questions