diff --git a/client/src/app/core/services/html-to-pdf.service.ts b/client/src/app/core/services/html-to-pdf.service.ts index 853952738..1f241ee02 100644 --- a/client/src/app/core/services/html-to-pdf.service.ts +++ b/client/src/app/core/services/html-to-pdf.service.ts @@ -93,7 +93,7 @@ export class HtmlToPdfService { const parser = new DOMParser(); const parsedHtml = parser.parseFromString(htmlText, 'text/html'); // Since the spread operator did not work for HTMLCollection, use Array.from - const htmlArray = Array.from(parsedHtml.body.children); + const htmlArray = Array.from(parsedHtml.body.childNodes); // Parse the children of the current HTML element for (const child of htmlArray) { @@ -219,6 +219,7 @@ export class HtmlToPdfService { } } else { const children = this.parseChildren(element, styles); + newParagraph = { ...this.create('text'), ...this.computeStyle(styles) diff --git a/client/src/app/core/services/pdf-document.service.ts b/client/src/app/core/services/pdf-document.service.ts index 934d6d221..b7fd85b6e 100644 --- a/client/src/app/core/services/pdf-document.service.ts +++ b/client/src/app/core/services/pdf-document.service.ts @@ -308,13 +308,18 @@ export class PdfDocumentService { } /** - * Downloads a pdf. Does not seem to work. + * Downloads a pdf. * * @param docDefinition the structure of the PDF document */ - public download(docDefinition: object, filename: string, metadata?: object): void { - this.getStandardPaper(docDefinition, metadata).then(doc => { - pdfMake.createPdf(doc).getBlob(blob => saveAs(blob, `${filename}.pdf`, { autoBOM: true })); + public async download(docDefinition: object, filename: string, metadata?: object): Promise { + const doc = await this.getStandardPaper(docDefinition, metadata); + await new Promise(resolve => { + const pdf = pdfMake.createPdf(doc); + pdf.getBlob(blob => { + saveAs(blob, `${filename}.pdf`, { autoBOM: true }); + resolve(true); + }); }); } @@ -347,6 +352,9 @@ export class PdfDocumentService { margin: [0, -20, 0, 20], color: 'grey' }, + preamble: { + margin: [0, 0, 0, 10] + }, headerText: { fontSize: 10, margin: [0, 10, 0, 0] @@ -362,10 +370,33 @@ export class PdfDocumentService { smallText: { fontSize: 8 }, + heading2: { + fontSize: 14, + margin: [0, 0, 0, 10], + bold: true + }, heading3: { fontSize: 12, margin: [0, 10, 0, 0], bold: true + }, + tocEntry: { + fontSize: 12, + margin: [0, 0, 0, 0], + bold: false + }, + tocCategoryEntry: { + fontSize: 12, + margin: [10, 0, 0, 0], + bold: false + }, + tocCategoryTitle: { + fontSize: 12, + margin: [0, 0, 0, 4], + bold: true + }, + tocCategorySection: { + margin: [0, 0, 0, 10] } }; } diff --git a/client/src/app/site/motions/components/motion-list/motion-list.component.html b/client/src/app/site/motions/components/motion-list/motion-list.component.html index db46bb07d..3e418fcb1 100644 --- a/client/src/app/site/motions/components/motion-list/motion-list.component.html +++ b/client/src/app/site/motions/components/motion-list/motion-list.component.html @@ -178,6 +178,10 @@ archive Export as CSV +