Mercurial > gemma
comparison client/src/lib/mixins.js @ 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 | 3878bc0c8e58 |
comparison
equal
deleted
inserted
replaced
3788:3ca5a83e46af | 3790:60977e18e227 |
---|---|
151 y = this.pdf.height - offset.y - height; | 151 y = this.pdf.height - offset.y - height; |
152 } | 152 } |
153 this.addRoundedBox(x, y, width, height, color, rounding, brcolor); | 153 this.addRoundedBox(x, y, width, height, color, rounding, brcolor); |
154 }, | 154 }, |
155 getTextHeight(numberOfLines) { | 155 getTextHeight(numberOfLines) { |
156 return numberOfLines * ((this.pdf.doc.getFontSize() * 25.4) / 80) * 1.15; // see https://github.com/yWorks/jsPDF/blob/master/jspdf.js#L207 | 156 // Return estimated height in mm. |
157 | |
158 // FontSize is given in desktop publishing points defined as 1/72 inch. | |
159 // aka 25.4 / 72 mm | |
160 let fontSize = this.pdf.doc.getFontSize(); | |
161 let lineHeightFactor = 1.15; // default from jspdf-yworks 2.0.2 | |
162 if (typeof this.pdf.doc.getLineHeightFactor !== "undefined") { | |
163 lineHeightFactor = this.pdf.doc.getLineHeightFactor(); | |
164 } | |
165 return numberOfLines * fontSize * (25.4 / 72) * lineHeightFactor; | |
157 }, | 166 }, |
158 // title for diagram | 167 // title for diagram |
159 addDiagramTitle(position, offset, size, color, text) { | 168 addDiagramTitle(position, offset, size, color, text) { |
160 let x = offset.x, | 169 let x = offset.x, |
161 y = offset.y; | 170 y = offset.y; |