Mercurial > gemma
comparison client/src/components/Pdftool.vue @ 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 | 3d2b55d2d8a6 |
children | 8fb1b1a8ea85 |
comparison
equal
deleted
inserted
replaced
1927:5a37ee321651 | 1928:76ca071cb006 |
---|---|
105 }; | 105 }; |
106 }, | 106 }, |
107 computed: { | 107 computed: { |
108 ...mapState("application", ["showPdfTool", "secondaryLogo"]), | 108 ...mapState("application", ["showPdfTool", "secondaryLogo"]), |
109 ...mapState("bottlenecks", ["selectedSurvey"]), | 109 ...mapState("bottlenecks", ["selectedSurvey"]), |
110 ...mapState("map", ["openLayersMap"]), | 110 ...mapState("map", ["openLayersMap", "isolinesLegendImgDataURL"]), |
111 ...mapState("user", ["user"]) | 111 ...mapState("user", ["user"]) |
112 }, | 112 }, |
113 methods: { | 113 methods: { |
114 download() { | 114 download() { |
115 // FUTURE: disable button while working on it | 115 // FUTURE: disable button while working on it |
213 */ | 213 */ |
214 //self.addText(pdf, 150, 20, 10, "black", 70, "some text"); | 214 //self.addText(pdf, 150, 20, 10, "black", 70, "some text"); |
215 self.addNorthArrow(pdf, 15, 9, northarrowSize); | 215 self.addNorthArrow(pdf, 15, 9, northarrowSize); |
216 self.addPageInfo(pdf); | 216 self.addPageInfo(pdf); |
217 self.addAboutBox(pdf, width, height); | 217 self.addAboutBox(pdf, width, height); |
218 | |
219 // addLegend | |
220 // transforming into an HTMLImageElement only to find out | |
221 // the width x height of the legend image | |
222 // FUTURE: find a better way to get the width and height | |
223 let legendImage = new Image(); | |
224 legendImage.src = self.isolinesLegendImgDataURL; | |
225 let aspectRatio = legendImage.width / legendImage.height; | |
226 | |
227 self.addRoundedBox(pdf, width - 54, 0, 54, 50 / aspectRatio + 4); | |
228 pdf.addImage(legendImage, width - 52, 2, 50, 50 / aspectRatio); | |
218 | 229 |
219 pdf.save("map.pdf"); | 230 pdf.save("map.pdf"); |
220 // reset to original size | 231 // reset to original size |
221 map.setSize(mapSize); | 232 map.setSize(mapSize); |
222 map.getView().fit(mapExtent, { size: mapSize }); | 233 map.getView().fit(mapExtent, { size: mapSize }); |