comparison client/src/lib/mixins.js @ 3154:b6c10b30d6bd

client: pdf-gen: add one pdf-template element * add textbox function to mixins * implemet this function in pdf-template for waterlevel diagram
author Fadi Abbud <fadi.abbud@intevation.de>
date Fri, 03 May 2019 15:08:27 +0200
parents d33a5c1522dc
children 429e28295902
comparison
equal deleted inserted replaced
3153:8159bd2aaf93 3154:b6c10b30d6bd
123 // draws a rounded background box at (x,y) width x height 123 // draws a rounded background box at (x,y) width x height
124 // using jsPDF units 124 // using jsPDF units
125 this.pdf.doc.setDrawColor(brcolor); 125 this.pdf.doc.setDrawColor(brcolor);
126 this.pdf.doc.setFillColor(color); 126 this.pdf.doc.setFillColor(color);
127 this.pdf.doc.roundedRect(x, y, w, h, rounding, rounding, "FD"); 127 this.pdf.doc.roundedRect(x, y, w, h, rounding, rounding, "FD");
128 },
129 addTextBox(
130 position,
131 offset,
132 width,
133 height,
134 rounding,
135 padding,
136 fontSize,
137 color,
138 background,
139 text,
140 brcolor
141 ) {
142 this.pdf.doc.setFontSize(fontSize);
143 text = this.replacePlaceholders(text);
144
145 if (!width) {
146 width = this.pdf.doc.getTextWidth(text) + 2 * padding;
147 }
148 let textWidth = width - 2 * padding;
149 if (!height) {
150 let textLines = this.pdf.doc.splitTextToSize(text, textWidth);
151 height = this.getTextHeight(textLines.length) + 2 * padding;
152 }
153
154 this.addBox(
155 position,
156 offset,
157 width,
158 height,
159 rounding,
160 background,
161 brcolor
162 );
163 this.addText(
164 position,
165 { x: offset.x + padding, y: offset.y + padding },
166 textWidth,
167 fontSize,
168 color,
169 text
170 );
128 } 171 }
129 } 172 }
130 }; 173 };
131 174
132 export { sortTable, pane, pdfgen }; 175 export { sortTable, pane, pdfgen };