Mercurial > gemma
changeset 3790:60977e18e227 yworks-svg2pdf
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.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 03 Jul 2019 16:53:06 +0200 |
parents | 3ca5a83e46af |
children | 6081743c0d98 |
files | client/src/components/Pdftool.vue client/src/lib/mixins.js |
diffstat | 2 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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() {
--- 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) {