Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom font faces for jspdf-autotable plugin

Can someone help with an example for setting custom fonts for jspdf-autotable

I tried the following

var doc = new jsPDF('p', 'pt');
doc.setFont("rotobo");      ----> font face name that I declared in my css file
doc.autoTable(columns, data);
doc.save("table.pdf");

After I tried this, the fonts in PDF did not change.

Any suggestions would be appreciated.

like image 245
naresh setty Avatar asked Nov 08 '16 02:11

naresh setty


2 Answers

You can use

console.log(doc.getFontList());

to check what fonts they support. It seems that they only support these fonts:

[Courier] [Helvetica] [Times] [ZapfDingbats] [courier]

If you want to show a check mark in your PDF file, this plug-in may not have the capabilities to do that...

like image 37
BetterTeng Avatar answered Sep 23 '22 18:09

BetterTeng


Try something like this.

doc.autoTable(columns, data, {styles: {font: "rotobo"}});

or

You can refer more on Custom style example here and the doc README.md shows all the styles.

like image 105
Danoja Dias Avatar answered Sep 23 '22 18:09

Danoja Dias