changeset 2296:da6611071a58

client: pdf-gen: fixed width calculation of textbox
author Markus Kottlaender <markus@intevation.de>
date Mon, 18 Feb 2019 11:22:31 +0100
parents b6cd295bf75d
children c8cc875d271c
files client/src/components/Pdftool.vue
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue	Mon Feb 18 11:16:13 2019 +0100
+++ b/client/src/components/Pdftool.vue	Mon Feb 18 11:22:31 2019 +0100
@@ -456,13 +456,14 @@
       background,
       text
     ) {
+      this.pdf.doc.setFontSize(fontSize);
+      text = this.replacePlaceholders(text);
+
       if (!width) {
-        width = Math.max(this.pdf.doc.getTextWidth(text)) + padding;
+        width = this.pdf.doc.getTextWidth(text) + 2 * padding;
       }
       let textWidth = width - 2 * padding;
       if (!height) {
-        this.pdf.doc.setFontSize(fontSize);
-        text = this.replacePlaceholders(text);
         let textLines = this.pdf.doc.splitTextToSize(text, textWidth);
         height = this.getTextHeight(textLines.length) + 2 * padding;
       }