Reputation: 1452
How do I specify letter spacing to text in jsPDF .text() method? This is the code I use now.
var doc = new jsPDF('p', 'mm', [183, 203]);
doc.setFontSize(9);
doc.setFont("monospace");
doc.text(39, 38, 'hello world');
doc.output('dataurl');
Upvotes: 0
Views: 5326
Reputation: 21
this will change the letter spacing of the entire pdf pdf.setCharSpace(5); 5 is the space that you give to the entire pdf, if you want to apply it only to a specific text it would be pdf.text('text', 30, 105, { charSpace: 5 });
Upvotes: 2
Reputation: 17898
Taken from jspdf.js, you can use lstext
function to specify letter spacing.
API.lstext = function (text, x, y, spacing) {
for (var i = 0, len = text.length; i < len; i++, x += spacing) this.text(text[i], x, y);
};
Usage should be,
doc.lstext('Hello World', 39, 38, 5);
Upvotes: 0