# HG changeset patch # User Bernhard Reiter # Date 1562165586 -7200 # Node ID 60977e18e2279766cb03f5ba210c2acde12232fd # Parent 3ca5a83e46aff1df68d99c5623ca2007d7b48b22 client: improve pdf generation getTextHeight() * Remove second appearance of getTextHeight() in PdfTool.vue. * Rectify getTextHeight() by adding a comment about what it does and correcting the calulcation to output millimeter. diff -r 3ca5a83e46af -r 60977e18e227 client/src/components/Pdftool.vue --- a/client/src/components/Pdftool.vue Wed Jul 03 16:44:45 2019 +0200 +++ b/client/src/components/Pdftool.vue Wed Jul 03 16:53:06 2019 +0200 @@ -829,13 +829,6 @@ textOptions ); } - }, - getTextHeight(numberOfLines) { - return ( - numberOfLines * - ((this.pdf.doc.getFontSize() * 25.4) / parseInt(this.form.resolution)) * - 1.15 // see https://github.com/yWorks/jsPDF/blob/master/jspdf.js#L207 - ); } }, mounted() { diff -r 3ca5a83e46af -r 60977e18e227 client/src/lib/mixins.js --- a/client/src/lib/mixins.js Wed Jul 03 16:44:45 2019 +0200 +++ b/client/src/lib/mixins.js Wed Jul 03 16:53:06 2019 +0200 @@ -153,7 +153,16 @@ this.addRoundedBox(x, y, width, height, color, rounding, brcolor); }, getTextHeight(numberOfLines) { - return numberOfLines * ((this.pdf.doc.getFontSize() * 25.4) / 80) * 1.15; // see https://github.com/yWorks/jsPDF/blob/master/jspdf.js#L207 + // Return estimated height in mm. + + // FontSize is given in desktop publishing points defined as 1/72 inch. + // aka 25.4 / 72 mm + let fontSize = this.pdf.doc.getFontSize(); + let lineHeightFactor = 1.15; // default from jspdf-yworks 2.0.2 + if (typeof this.pdf.doc.getLineHeightFactor !== "undefined") { + lineHeightFactor = this.pdf.doc.getLineHeightFactor(); + } + return numberOfLines * fontSize * (25.4 / 72) * lineHeightFactor; }, // title for diagram addDiagramTitle(position, offset, size, color, text) {