feature: generate pdf from actor

This commit is contained in:
Matthieu CAILLEAUX
2021-10-19 00:32:49 +02:00
parent c66feaf642
commit 338315eed6
6 changed files with 267 additions and 16 deletions

View File

@@ -28,14 +28,16 @@ export class Column extends AbstractElement {
}
public getHeight(doc): number {
return this.elements
.map((e) => e.getHeight(doc))
.reduce((p, c, i) => {
if (i === 0) {
return c;
}
return p + c + 2;
});
return this.elements.length > 0
? this.elements
.map((e) => e.getHeight(doc))
.reduce((p, c, i) => {
if (i === 0) {
return c;
}
return p + c + 2;
})
: 0;
}
public getCheckNewPageHeight(doc?: jsPDF): number {

View File

@@ -25,7 +25,7 @@ export class LabelledValues extends Row {
const labelPercent = 100 - valuePercent;
const widthPercent = [labelPercent, valuePercent];
let currentIndex = 0;
if (labelledValues.length >= this.nbrOfCol) {
if (this.nbrOfCol > 1) {
const nbrPerCol = Math.floor(labelledValues.length / this.nbrOfCol);
const rest = labelledValues.length - nbrPerCol * this.nbrOfCol;
const nbrPerCols = [

View File

@@ -23,7 +23,7 @@ export class Texts extends Row {
this.nbrOfCol = 4;
}
let currentIndex = 0;
if (texts.length >= this.nbrOfCol) {
if (this.nbrOfCol > 1) {
const nbrPerCol = Math.floor(texts.length / this.nbrOfCol);
const rest = texts.length - nbrPerCol * this.nbrOfCol;
const nbrPerCols = [