Mercurial > gemma
comparison client/src/lib/mixins.js @ 3799:f4deb4aae485 yworks-svg2pdf
client: improve pdf generation
* Refactor Fairwayprofile.vue to use generatedPDF() from mixins.js.
* Fix generatedPDF() to use parameters for templateData at one remaining point.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Thu, 04 Jul 2019 10:29:48 +0200 |
parents | e008197e2215 |
children | 1399d31531f7 |
comparison
equal
deleted
inserted
replaced
3798:e008197e2215 | 3799:f4deb4aae485 |
---|---|
82 ")" | 82 ")" |
83 ); | 83 ); |
84 }, | 84 }, |
85 generatePDF(params) { | 85 generatePDF(params) { |
86 // creates a new jsPDF object into this.pdf.doc | 86 // creates a new jsPDF object into this.pdf.doc |
87 // will call functions that the calling context has to provide | |
88 // as specified in the templateData | |
87 let templateData = params["templateData"]; | 89 let templateData = params["templateData"]; |
88 let diagramTitle = params["diagramTitle"]; | 90 let diagramTitle = params["diagramTitle"]; |
89 | 91 |
90 this.pdf.doc = new jsPDF( | 92 this.pdf.doc = new jsPDF("l", "mm", templateData.properties.paperSize); |
91 "l", | |
92 "mm", | |
93 this.templateData.properties.paperSize | |
94 ); | |
95 // pdf width and height in millimeter (landscape) | 93 // pdf width and height in millimeter (landscape) |
96 if (templateData.properties.paperSize === "a3") { | 94 if (templateData.properties.paperSize === "a3") { |
97 this.pdf.width = 420; | 95 this.pdf.width = 420; |
98 this.pdf.height = 297; | 96 this.pdf.height = 297; |
99 } else { | 97 } else { |
187 } | 185 } |
188 } | 186 } |
189 }); | 187 }); |
190 } | 188 } |
191 }, | 189 }, |
192 | |
193 // add text at specific coordinates and do line breaks | 190 // add text at specific coordinates and do line breaks |
194 addText(position, offset, width, fontSize, color, text) { | 191 addText(position, offset, width, fontSize, color, text) { |
195 text = this.replacePlaceholders(text); | 192 text = this.replacePlaceholders(text); |
196 // split the incoming string to an array, each element is a string of | 193 // split the incoming string to an array, each element is a string of |
197 // words in a single line | 194 // words in a single line |