feature: generate pdf from actor

This commit is contained in:
Matthieu CAILLEAUX
2021-10-18 00:35:13 +02:00
parent f96372b236
commit 145207a1c5
14 changed files with 391 additions and 138 deletions

View File

@@ -21,7 +21,7 @@ export class Row extends AbstractElement {
this.maxWidths = maxWidths ?? [];
}
public render(doc: jsPDF, maxWidth?: number): jsPDF {
public prepareRender(doc: jsPDF, maxWidth?: number): jsPDF {
const elements = this.elements ?? [];
let maxWidths = this.maxWidths ?? [];
let widthPercents = this.widthPercents ?? [];
@@ -50,12 +50,16 @@ export class Row extends AbstractElement {
const maxChildWidth = maxWidths[i] ?? percentWidth;
element.x = currentX;
element.y = this.y;
element.render(doc, maxChildWidth);
element.prepareRender(doc, maxChildWidth);
currentX += percentWidth;
}
return doc;
}
public render(doc: jsPDF, _maxWidth?: number): jsPDF {
return doc;
}
public getHeight(doc?: jsPDF): number {
let maxHeight = 0;
for (const element of this.elements) {
@@ -63,4 +67,20 @@ export class Row extends AbstractElement {
}
return maxHeight;
}
public getCheckNewPageHeight(doc?: jsPDF): number {
let maxHeight = 0;
for (const element of this.elements) {
maxHeight = Math.max(maxHeight, element.getCheckNewPageHeight(doc));
}
return maxHeight;
}
public getElements(): AbstractElement[] {
const elements: AbstractElement[] = [];
for (const element of this.elements) {
elements.push(...element.getElements());
}
return elements;
}
}