Javascript jsPDF调整文本行间距
在jsPDF中,我找不到增加文本行间距的方法或函数。我想知道是否有知识渊博的人会点头同意分享一些他/她的知识:)。多谢 API.text的输出使用lineHeightProportion确定行高:Javascript jsPDF调整文本行间距,javascript,jquery,jspdf,Javascript,Jquery,Jspdf,在jsPDF中,我找不到增加文本行间距的方法或函数。我想知道是否有知识渊博的人会点头同意分享一些他/她的知识:)。多谢 API.text的输出使用lineHeightProportion确定行高: out( 'BT\n/' + activeFontKey + ' ' + activeFontSize + ' Tf\n' + // font face, style, size (activeFo
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'
);
将上述各行更改为
// (activeFontSize * lineHeightProportion) + ' TL\n' + // line spacing
(activeFontSize * this.lineHeightProportion) + ' TL\n' + // line spacing
以及设置变量:
pdf = new jsPDF("portrait", "in", "letter");
pdf.lineHeightProportion = 2;
我们应该做到这一点
您还可以在jsPDF构造函数中添加参数:
file = new jsPDF({orientation: "p", lineHeight: 1.5)})
从jsPDF代码(函数jsPDF(方向、单位、格式、压缩PDF)):
您的意思是在
text
函数中使用字符串数组时?
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