Mercurial > gemma
comparison client/src/components/Pdftool.vue @ 2222:318da99d406a pdf-export
PDF generation: fix text size calculation
For jsPDF to correctly calculate the display size of text, it's important
that all font properties are set before the calculation. Makes sense...
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 11 Feb 2019 10:38:36 +0100 |
parents | 74c7d84f93d7 |
children | 85142493096c |
comparison
equal
deleted
inserted
replaced
2221:74c7d84f93d7 | 2222:318da99d406a |
---|---|
516 if (text.includes("{user}")) { | 516 if (text.includes("{user}")) { |
517 text = text.replace("{user}", this.user); | 517 text = text.replace("{user}", this.user); |
518 } | 518 } |
519 | 519 |
520 // split the incoming string to an array, each element is a string of words in a single line | 520 // split the incoming string to an array, each element is a string of words in a single line |
521 var textLines = this.pdf.doc.splitTextToSize(text, width - 2 * padding); | |
522 this.pdf.doc.setTextColor(color); | 521 this.pdf.doc.setTextColor(color); |
523 this.pdf.doc.setFontSize(fontSize); | 522 this.pdf.doc.setFontSize(fontSize); |
523 var textLines = this.pdf.doc.splitTextToSize(text, width - 2 * padding); | |
524 this.pdf.doc.text(x + padding, y + padding, textLines); | 524 this.pdf.doc.text(x + padding, y + padding, textLines); |
525 }, | 525 }, |
526 addImage(url, format, position, offset, width, height, border) { | 526 addImage(url, format, position, offset, width, height, border) { |
527 // x/y defaults to offset for topleft corner (normal x/y coordinates) | 527 // x/y defaults to offset for topleft corner (normal x/y coordinates) |
528 let x = offset.x; | 528 let x = offset.x; |