changeset 1928:76ca071cb006

client: pdf-gen: add legend graphic * Add a plain legend graphic to the right upper corner. Take a detour via a HTMLImageElement to get the aspect ration of the legend graphic and calculate the necessary size accordingly.
author Bernhard Reiter <bernhard@intevation.de>
date Mon, 21 Jan 2019 11:37:24 +0100
parents 5a37ee321651
children f538d9a23329
files client/src/components/Pdftool.vue
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue	Mon Jan 21 10:56:14 2019 +0100
+++ b/client/src/components/Pdftool.vue	Mon Jan 21 11:37:24 2019 +0100
@@ -107,7 +107,7 @@
   computed: {
     ...mapState("application", ["showPdfTool", "secondaryLogo"]),
     ...mapState("bottlenecks", ["selectedSurvey"]),
-    ...mapState("map", ["openLayersMap"]),
+    ...mapState("map", ["openLayersMap", "isolinesLegendImgDataURL"]),
     ...mapState("user", ["user"])
   },
   methods: {
@@ -216,6 +216,17 @@
         self.addPageInfo(pdf);
         self.addAboutBox(pdf, width, height);
 
+        // addLegend
+        // 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
+        let legendImage = new Image();
+        legendImage.src = self.isolinesLegendImgDataURL;
+        let aspectRatio = legendImage.width / legendImage.height;
+
+        self.addRoundedBox(pdf, width - 54, 0, 54, 50 / aspectRatio + 4);
+        pdf.addImage(legendImage, width - 52, 2, 50, 50 / aspectRatio);
+
         pdf.save("map.pdf");
         // reset to original size
         map.setSize(mapSize);