diff --git a/src/main/resources/static/js/multitool/PdfContainer.js b/src/main/resources/static/js/multitool/PdfContainer.js index d87fd6cb..1fa836c3 100644 --- a/src/main/resources/static/js/multitool/PdfContainer.js +++ b/src/main/resources/static/js/multitool/PdfContainer.js @@ -165,43 +165,14 @@ class PdfContainer { async addFilesBlank(nextSiblingElement) { - const pdfContent = ` - %PDF-1.4 - 1 0 obj - << /Type /Catalog /Pages 2 0 R >> - endobj - 2 0 obj - << /Type /Pages /Kids [3 0 R] /Count 1 >> - endobj - 3 0 obj - << /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Contents 5 0 R >> - endobj - 5 0 obj - << /Length 44 >> - stream - 0 0 0 595 0 842 re - W - n - endstream - endobj - xref - 0 6 - 0000000000 65535 f - 0000000010 00000 n - 0000000071 00000 n - 0000000121 00000 n - 0000000205 00000 n - 0000000400 00000 n - trailer - << /Size 6 /Root 1 0 R >> - startxref - 278 - %%EOF - `; - const blob = new Blob([pdfContent], { type: 'application/pdf' }); - const url = URL.createObjectURL(blob); - const file = new File([blob], "blank_page.pdf", { type: "application/pdf" }); - await this.addPdfFile(file, nextSiblingElement); + let doc = await PDFLib.PDFDocument.create(); + let docBytes = await doc.save(); + + const url = URL.createObjectURL(new Blob([docBytes], { type: 'application/pdf' })); + + const renderer = await this.toRenderer(url); + + await this.addPdfFile(renderer, doc, nextSiblingElement); }