jsPDF adjust the text-line spacing
You can also add parameters in the jsPDF constructor:
file = new jsPDF({orientation: "p", lineHeight: 1.5)})
From jsPDF code (function jsPDF(orientation, unit, format, compressPdf)):
var options = {};
if (typeof orientation === 'object') {
options = orientation;
orientation = options.orientation;
unit = options.unit || unit;
format = options.format || format;
compressPdf = options.compress || options.compressPdf || compressPdf;
}
// Default options
unit = unit || 'mm';
format = format || 'a4';
orientation = ('' + (orientation || 'P')).toLowerCase();
var format_as_string = ('' + format).toLowerCase(),
compress = !!compressPdf && typeof Uint8Array === 'function',
textColor = options.textColor || '0 g',
drawColor = options.drawColor || '0 G',
activeFontSize = options.fontSize || 16,
lineHeightProportion = options.lineHeight || 1.15,
lineWidth = options.lineWidth || 0.200025; // 2mm
The output of API.text determines line height using lineHeightProportion:
out(
'BT\n/' +
activeFontKey + ' ' + activeFontSize + ' Tf\n' + // font face, style, size
(activeFontSize * lineHeightProportion) + ' TL\n' + // line spacing
textColor +
'\n' + f2(x * k) + ' ' + f2((pageHeight - y) * k) + ' Td\n(' +
str +
') Tj\nET'
);
changing the above respective line to
// (activeFontSize * lineHeightProportion) + ' TL\n' + // line spacing
(activeFontSize * this.lineHeightProportion) + ' TL\n' + // line spacing
and setting the variable:
pdf = new jsPDF("portrait", "in", "letter");
pdf.lineHeightProportion = 2;
should do the trick.
https://github.com/MrRio/jsPDF/pull/167