Mercurial > gemma
comparison client/src/lib/mixins.js @ 3293:76f643d20f19
clinet: pdf-gen: (cleanup) remove some pdf-functions from pdftool
* delete some pdf-functions in pdftool, the reusable functions are defind in mixins.js
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Thu, 16 May 2019 14:35:48 +0200 |
parents | aac1ca73e92a |
children | db1dc197dc43 |
comparison
equal
deleted
inserted
replaced
3292:7a88b37bce8b | 3293:76f643d20f19 |
---|---|
61 } | 61 } |
62 }; | 62 }; |
63 | 63 |
64 export const pdfgen = { | 64 export const pdfgen = { |
65 methods: { | 65 methods: { |
66 // add text at specific coordinates and determine how many wrolds in a single line | |
66 addText(position, offset, width, fontSize, color, text) { | 67 addText(position, offset, width, fontSize, color, text) { |
67 text = this.replacePlaceholders(text); | 68 text = this.replacePlaceholders(text); |
68 // split the incoming string to an array, each element is a string of | 69 // split the incoming string to an array, each element is a string of |
69 // words in a single line | 70 // words in a single line |
70 this.pdf.doc.setTextColor(color); | 71 this.pdf.doc.setTextColor(color); |
106 return text; | 107 return text; |
107 }, | 108 }, |
108 addImage(url, format, position, offset, width, height) { | 109 addImage(url, format, position, offset, width, height) { |
109 let x = offset.x; | 110 let x = offset.x; |
110 let y = offset.y; | 111 let y = offset.y; |
112 //roundup-intern.intevation.de/wamos/issue416 | |
111 if (["topright", "bottomright"].indexOf(position) !== -1) { | 113 if (["topright", "bottomright"].indexOf(position) !== -1) { |
112 x = this.pdf.width - offset.x - width; | 114 x = this.pdf.width - offset.x - width; |
113 } | 115 } |
114 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { | 116 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { |
115 y = this.pdf.height - offset.y - height; | 117 y = this.pdf.height - offset.y - height; |
124 image.src = "/img/gemma-logo-for-pdf.png"; | 126 image.src = "/img/gemma-logo-for-pdf.png"; |
125 } | 127 } |
126 } | 128 } |
127 this.pdf.doc.addImage(image, x, y, width, height); | 129 this.pdf.doc.addImage(image, x, y, width, height); |
128 }, | 130 }, |
131 // add text at specific coordinates with a background box | |
129 addBox(position, offset, width, height, rounding, color, brcolor) { | 132 addBox(position, offset, width, height, rounding, color, brcolor) { |
130 // x/y defaults to offset for topleft corner (normal x/y coordinates) | 133 // x/y defaults to offset for topleft corner (normal x/y coordinates) |
131 let x = offset.x; | 134 let x = offset.x; |
132 let y = offset.y; | 135 let y = offset.y; |
133 | 136 |
168 this.pdf.doc.setFontSize(size); | 171 this.pdf.doc.setFontSize(size); |
169 this.pdf.doc.setFontStyle("bold"); | 172 this.pdf.doc.setFontStyle("bold"); |
170 this.pdf.doc.text(text, x, y, { baseline: "hanging" }); | 173 this.pdf.doc.text(text, x, y, { baseline: "hanging" }); |
171 }, | 174 }, |
172 addRoundedBox(x, y, w, h, color, rounding, brcolor) { | 175 addRoundedBox(x, y, w, h, color, rounding, brcolor) { |
173 // draws a rounded background box at (x,y) width x height | |
174 // using jsPDF units | |
175 this.pdf.doc.setDrawColor(brcolor); | 176 this.pdf.doc.setDrawColor(brcolor); |
176 this.pdf.doc.setFillColor(color); | 177 this.pdf.doc.setFillColor(color); |
177 this.pdf.doc.roundedRect(x, y, w, h, rounding, rounding, "FD"); | 178 this.pdf.doc.roundedRect(x, y, w, h, rounding, rounding, "FD"); |
178 }, | 179 }, |
179 addTextBox( | 180 addTextBox( |