Mercurial > gemma
diff client/src/lib/mixins.js @ 3154:b6c10b30d6bd
client: pdf-gen: add one pdf-template element
* add textbox function to mixins
* implemet this function in pdf-template for waterlevel diagram
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Fri, 03 May 2019 15:08:27 +0200 |
parents | d33a5c1522dc |
children | 429e28295902 |
line wrap: on
line diff
--- a/client/src/lib/mixins.js Fri May 03 14:23:47 2019 +0200 +++ b/client/src/lib/mixins.js Fri May 03 15:08:27 2019 +0200 @@ -125,6 +125,49 @@ this.pdf.doc.setDrawColor(brcolor); this.pdf.doc.setFillColor(color); this.pdf.doc.roundedRect(x, y, w, h, rounding, rounding, "FD"); + }, + addTextBox( + position, + offset, + width, + height, + rounding, + padding, + fontSize, + color, + background, + text, + brcolor + ) { + this.pdf.doc.setFontSize(fontSize); + text = this.replacePlaceholders(text); + + if (!width) { + width = this.pdf.doc.getTextWidth(text) + 2 * padding; + } + let textWidth = width - 2 * padding; + if (!height) { + let textLines = this.pdf.doc.splitTextToSize(text, textWidth); + height = this.getTextHeight(textLines.length) + 2 * padding; + } + + this.addBox( + position, + offset, + width, + height, + rounding, + background, + brcolor + ); + this.addText( + position, + { x: offset.x + padding, y: offset.y + padding }, + textWidth, + fontSize, + color, + text + ); } } };