Mercurial > gemma
diff client/src/components/Pdftool.vue @ 2215:82867a69e10e pdf-export
merged default in pdf-export
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Thu, 07 Feb 2019 11:27:07 +0100 |
parents | 5a4b0c85e7a8 4a903d382901 |
children | 631ca0412db9 |
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue Thu Feb 07 10:38:17 2019 +0100 +++ b/client/src/components/Pdftool.vue Thu Feb 07 11:27:07 2019 +0100 @@ -144,7 +144,7 @@ }, computed: { ...mapState("application", ["showPdfTool", "logoForPDF", "pdfTemplates"]), - ...mapState("bottlenecks", ["selectedSurvey"]), + ...mapState("bottlenecks", ["selectedBottleneck", "selectedSurvey"]), ...mapState("map", ["openLayersMap", "isolinesLegendImgDataURL"]), ...mapGetters("map", ["getLayerByName"]), ...mapState("user", ["user"]) @@ -254,7 +254,8 @@ //self.addAboutBox(pdf, width, height); if (self.getLayerByName("Bottleneck isolines").isVisible) { - self.addLegend(pdf, width, height); + self.addBottleneckInfo(pdf, 13, width, height); + self.addLegend(pdf, 14, width, height); } if (template) { template.elements.forEach(t => { @@ -406,7 +407,7 @@ unit = "km"; unitConversionFactor = 1e6; } else if (maxLength >= 1e4) { - // >= 10 m) + // >= 10 m unit = "m"; unitConversionFactor = 1e3; } @@ -519,7 +520,7 @@ "Dislaimer: Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."; this.addText(doc, 5, docHeight - 6, 8, "black", 115, str); }, - addLegend(doc, docWidth) { + addLegend(doc, fromTop, docWidth) { // transforming into an HTMLImageElement only to find out // the width x height of the legend image // FUTURE: find a better way to get the width and height @@ -527,8 +528,46 @@ legendImage.src = this.isolinesLegendImgDataURL; let aspectRatio = legendImage.width / legendImage.height; - this.addRoundedBox(doc, docWidth - 54, 0, 54, 50 / aspectRatio + 4); - doc.addImage(legendImage, docWidth - 52, 2, 50, 50 / aspectRatio); + this.addRoundedBox(doc, docWidth - 54, fromTop, 54, 50 / aspectRatio + 4); + doc.addImage( + legendImage, + docWidth - 52, + fromTop + 2, + 50, + 50 / aspectRatio + ); + }, + addBottleneckInfo(doc, height, docWidth) { + this.addRoundedBox(doc, docWidth - 54, 0, 54, height); + + console.log("Fontlist =", doc.getFontList()); + doc.setFont("times", "normal"); + + let name, w, str; + + 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); + + 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); + + 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); } }, mounted() {