changeset 2138:4a903d382901

client: pdf-gen: make bottleneck infos more fancy * Use different font styles to beautify the bottleneck details on the pdf. This also demonstrates how to calculate the size of text elements for laout purposes.
author Bernhard Reiter <bernhard@intevation.de>
date Wed, 06 Feb 2019 17:05:10 +0100
parents a31c9fa47ab8
children 22bbd0d0500e
files client/src/components/Pdftool.vue
diffstat 1 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue	Wed Feb 06 16:26:39 2019 +0100
+++ b/client/src/components/Pdftool.vue	Wed Feb 06 17:05:10 2019 +0100
@@ -486,16 +486,35 @@
     },
     addBottleneckInfo(doc, height, docWidth) {
       this.addRoundedBox(doc, docWidth - 54, 0, 54, height);
-      let str1 = this.$gettext("Bottleneck") + ": " + this.selectedBottleneck;
-      this.addText(doc, docWidth - 51, 4, 8, "black", 46, str1);
+
+      console.log("Fontlist =", doc.getFontList());
+      doc.setFont("times", "normal");
+
+      let name, w, str;
 
-      let survey = this.selectedSurvey;
+      doc.setFontStyle("italic");
+      name = this.$gettext("Bottleneck") + ": ";
+      w = doc.getTextWidth(name);
+      this.addText(doc, docWidth - 51, 4, 8, "black", 46, name);
+      doc.setFontStyle("bold");
+      str = this.selectedBottleneck;
+      this.addText(doc, docWidth - 51 + w, 4, 8, "black", 46, str);
 
-      let str2 = this.$gettext("Survey date") + ": " + survey.date_info;
-      this.addText(doc, docWidth - 51, 7.5, 8, "black", 46, str2);
+      doc.setFontStyle("italic");
+      name = this.$gettext("Survey date") + ": ";
+      w = doc.getTextWidth(name);
+      this.addText(doc, docWidth - 51, 7.5, 8, "black", 46, name);
+      doc.setFontStyle("normal");
+      str = this.selectedSurvey.date_info;
+      this.addText(doc, docWidth - 51 + w, 7.5, 8, "black", 46, str);
 
-      let str3 = this.$gettext("Ref gauge") + ": " + survey.gauge_objname;
-      this.addText(doc, docWidth - 51, 11, 8, "black", 46, str3);
+      doc.setFontStyle("italic");
+      name = this.$gettext("Ref gauge") + ": ";
+      w = doc.getTextWidth(name);
+      this.addText(doc, docWidth - 51, 11, 8, "black", 46, name);
+      doc.setFontStyle("normal");
+      str = this.selectedSurvey.gauge_objname;
+      this.addText(doc, docWidth - 51 + w, 11, 8, "black", 46, str);
     }
   }
 };