Mercurial > gemma
comparison 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 |
comparison
equal
deleted
inserted
replaced
2214:5a4b0c85e7a8 | 2215:82867a69e10e |
---|---|
142 readyToGenerate: true // if the user is allowed to press the button | 142 readyToGenerate: true // if the user is allowed to press the button |
143 }; | 143 }; |
144 }, | 144 }, |
145 computed: { | 145 computed: { |
146 ...mapState("application", ["showPdfTool", "logoForPDF", "pdfTemplates"]), | 146 ...mapState("application", ["showPdfTool", "logoForPDF", "pdfTemplates"]), |
147 ...mapState("bottlenecks", ["selectedSurvey"]), | 147 ...mapState("bottlenecks", ["selectedBottleneck", "selectedSurvey"]), |
148 ...mapState("map", ["openLayersMap", "isolinesLegendImgDataURL"]), | 148 ...mapState("map", ["openLayersMap", "isolinesLegendImgDataURL"]), |
149 ...mapGetters("map", ["getLayerByName"]), | 149 ...mapGetters("map", ["getLayerByName"]), |
150 ...mapState("user", ["user"]) | 150 ...mapState("user", ["user"]) |
151 }, | 151 }, |
152 methods: { | 152 methods: { |
252 self.addNorthArrow(pdf, 15, 9, northarrowSize); | 252 self.addNorthArrow(pdf, 15, 9, northarrowSize); |
253 //self.addPageInfo(pdf); | 253 //self.addPageInfo(pdf); |
254 //self.addAboutBox(pdf, width, height); | 254 //self.addAboutBox(pdf, width, height); |
255 | 255 |
256 if (self.getLayerByName("Bottleneck isolines").isVisible) { | 256 if (self.getLayerByName("Bottleneck isolines").isVisible) { |
257 self.addLegend(pdf, width, height); | 257 self.addBottleneckInfo(pdf, 13, width, height); |
258 self.addLegend(pdf, 14, width, height); | |
258 } | 259 } |
259 if (template) { | 260 if (template) { |
260 template.elements.forEach(t => { | 261 template.elements.forEach(t => { |
261 switch (t.type) { | 262 switch (t.type) { |
262 case "image": { | 263 case "image": { |
404 if (maxLength >= 1e7) { | 405 if (maxLength >= 1e7) { |
405 // >= 10 km | 406 // >= 10 km |
406 unit = "km"; | 407 unit = "km"; |
407 unitConversionFactor = 1e6; | 408 unitConversionFactor = 1e6; |
408 } else if (maxLength >= 1e4) { | 409 } else if (maxLength >= 1e4) { |
409 // >= 10 m) | 410 // >= 10 m |
410 unit = "m"; | 411 unit = "m"; |
411 unitConversionFactor = 1e3; | 412 unitConversionFactor = 1e3; |
412 } | 413 } |
413 | 414 |
414 maxLength /= unitConversionFactor; | 415 maxLength /= unitConversionFactor; |
517 | 518 |
518 let str = | 519 let str = |
519 "Dislaimer: Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."; | 520 "Dislaimer: Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."; |
520 this.addText(doc, 5, docHeight - 6, 8, "black", 115, str); | 521 this.addText(doc, 5, docHeight - 6, 8, "black", 115, str); |
521 }, | 522 }, |
522 addLegend(doc, docWidth) { | 523 addLegend(doc, fromTop, docWidth) { |
523 // transforming into an HTMLImageElement only to find out | 524 // transforming into an HTMLImageElement only to find out |
524 // the width x height of the legend image | 525 // the width x height of the legend image |
525 // FUTURE: find a better way to get the width and height | 526 // FUTURE: find a better way to get the width and height |
526 let legendImage = new Image(); | 527 let legendImage = new Image(); |
527 legendImage.src = this.isolinesLegendImgDataURL; | 528 legendImage.src = this.isolinesLegendImgDataURL; |
528 let aspectRatio = legendImage.width / legendImage.height; | 529 let aspectRatio = legendImage.width / legendImage.height; |
529 | 530 |
530 this.addRoundedBox(doc, docWidth - 54, 0, 54, 50 / aspectRatio + 4); | 531 this.addRoundedBox(doc, docWidth - 54, fromTop, 54, 50 / aspectRatio + 4); |
531 doc.addImage(legendImage, docWidth - 52, 2, 50, 50 / aspectRatio); | 532 doc.addImage( |
533 legendImage, | |
534 docWidth - 52, | |
535 fromTop + 2, | |
536 50, | |
537 50 / aspectRatio | |
538 ); | |
539 }, | |
540 addBottleneckInfo(doc, height, docWidth) { | |
541 this.addRoundedBox(doc, docWidth - 54, 0, 54, height); | |
542 | |
543 console.log("Fontlist =", doc.getFontList()); | |
544 doc.setFont("times", "normal"); | |
545 | |
546 let name, w, str; | |
547 | |
548 doc.setFontStyle("italic"); | |
549 name = this.$gettext("Bottleneck") + ": "; | |
550 w = doc.getTextWidth(name); | |
551 this.addText(doc, docWidth - 51, 4, 8, "black", 46, name); | |
552 doc.setFontStyle("bold"); | |
553 str = this.selectedBottleneck; | |
554 this.addText(doc, docWidth - 51 + w, 4, 8, "black", 46, str); | |
555 | |
556 doc.setFontStyle("italic"); | |
557 name = this.$gettext("Survey date") + ": "; | |
558 w = doc.getTextWidth(name); | |
559 this.addText(doc, docWidth - 51, 7.5, 8, "black", 46, name); | |
560 doc.setFontStyle("normal"); | |
561 str = this.selectedSurvey.date_info; | |
562 this.addText(doc, docWidth - 51 + w, 7.5, 8, "black", 46, str); | |
563 | |
564 doc.setFontStyle("italic"); | |
565 name = this.$gettext("Ref gauge") + ": "; | |
566 w = doc.getTextWidth(name); | |
567 this.addText(doc, docWidth - 51, 11, 8, "black", 46, name); | |
568 doc.setFontStyle("normal"); | |
569 str = this.selectedSurvey.gauge_objname; | |
570 this.addText(doc, docWidth - 51 + w, 11, 8, "black", 46, str); | |
532 } | 571 } |
533 }, | 572 }, |
534 mounted() { | 573 mounted() { |
535 this.$store.dispatch("application/loadPdfTemplates").then(() => { | 574 this.$store.dispatch("application/loadPdfTemplates").then(() => { |
536 this.form.template = this.pdfTemplates[0]; | 575 this.form.template = this.pdfTemplates[0]; |