comparison client/src/components/Pdftool.vue @ 2080:1dafdbfca100

client: pdf-gen: clean up: addtext function * stop addtext function from drawiang backgrund its already in another function
author Fadi Abbud <fadi.abbud@intevation.de>
date Thu, 31 Jan 2019 11:29:43 +0100
parents b275d5e14087
children dd4e1f5f66b8
comparison
equal deleted inserted replaced
2079:9318973487a1 2080:1dafdbfca100
358 }, 358 },
359 // add some text at specific coordinates and determine how many wrolds in single line 359 // add some text at specific coordinates and determine how many wrolds in single line
360 addText(doc, postitionX, positionY, size, color, lineWidth, text) { 360 addText(doc, postitionX, positionY, size, color, lineWidth, text) {
361 // split the incoming string to an array, each element is a string of words in a single line 361 // split the incoming string to an array, each element is a string of words in a single line
362 var textLines = doc.splitTextToSize(text, lineWidth); 362 var textLines = doc.splitTextToSize(text, lineWidth);
363 // get the longest line to fit the white backround to it
364 var longestString = "";
365 textLines.forEach(function(element) {
366 if (element.length > longestString.length) longestString = element;
367 });
368 var indexOfMaxString = textLines.indexOf(longestString);
369 // white background (rectangular) around the text
370 doc.setFillColor(255, 255, 255);
371 doc.setDrawColor(255, 255, 255);
372 doc.rect(
373 postitionX - doc.getStringUnitWidth(textLines[indexOfMaxString]) / size,
374 size > 10 ? positionY - size / 1.8 : positionY - size / 2.4,
375 doc.getStringUnitWidth(textLines[indexOfMaxString]) * (size / 2.6),
376 textLines.length * (size / 2),
377 "FD"
378 );
379 //rounded rectangular
380 /* doc.roundedRect(
381 postitionX - doc.getStringUnitWidth(textLines[indexOfMaxString]) / size,
382 size > 10 ? positionY - size / 1.8 : positionY - size / 2.6,
383 doc.getStringUnitWidth(textLines[indexOfMaxString]) * (size / 2.6),
384 textLines.length * (size / 2),
385 3,
386 3,
387 "FD"
388 ); */
389 doc.setTextColor(color); 363 doc.setTextColor(color);
390 doc.setFontSize(size); 364 doc.setFontSize(size);
391 doc.text(postitionX, positionY, textLines); 365 doc.text(postitionX, positionY, textLines);
392 }, 366 },
393 addPageInfo(doc) { 367 addPageInfo(doc) {