# HG changeset patch # User Bernhard Reiter # Date 1549469110 -3600 # Node ID 4a903d3829013cb622ea067c926cc4339e748e9c # Parent a31c9fa47ab8826286023c77fdda3431461cc0c3 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. diff -r a31c9fa47ab8 -r 4a903d382901 client/src/components/Pdftool.vue --- 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); } } };