diff --git a/src/jspdf.js b/src/jspdf.js index 834668e9a..7b281b139 100644 --- a/src/jspdf.js +++ b/src/jspdf.js @@ -3616,7 +3616,8 @@ function jsPDF(options) { //baseline var height = activeFontSize / scope.internal.scaleFactor; - var descent = height * (lineHeightFactor - 1); + var descent = height * (lineHeight - 1); + switch (options.baseline) { case "bottom": y -= descent; diff --git a/test/specs/jspdf.unit.spec.js b/test/specs/jspdf.unit.spec.js index 23c7818c5..b24dc2064 100644 --- a/test/specs/jspdf.unit.spec.js +++ b/test/specs/jspdf.unit.spec.js @@ -2523,6 +2523,21 @@ This is a test too.`, ]); }); + it('jsPDF test text with line height', function() { + const doc1 = new jsPDF(); + let writeArray1 = []; + doc1.__private__.setCustomOutputDestination(writeArray1); + doc1.setLineHeightFactor(1.5); + doc1.text('Some text', 10, 10, { baseline: 'middle' }); + + let writeArray2 = []; + const doc2 = new jsPDF(); + doc2.__private__.setCustomOutputDestination(writeArray2); + doc2.text('Some text', 10, 10, { lineHeightFactor: 1.5, baseline: 'middle' }); + + expect(writeArray1).toEqual(writeArray2); +}); + it("jsPDF private function setLineCap", () => { var doc = jsPDF({ floatPrecision: 2 });