Estoy usando pdf maker en mi aplicación StencilJs usando la documentación oficial enhttps://pdfmake.github.io/docs/0.1/getting-started/client-side/ En primer lugar, lo instalé a través de npm usando:
npm install pdfmakeLuego he creado lo siguiente para probar la funcionalidad:
import * as pdfMake from 'pdfmake/build/pdfmake'; import * as pdfFonts from 'pdfmake/build/vfs_fonts'; (<any>pdfMake).vfs = pdfFonts.pdfMake.vfs; export class PDFCreateService { constructor() { // empty } public createNachrichtPDF(message: string): any { const fileName: string = 'ba-postfach-' + moment(new Date()).format('DD-MM-YYYY'); const docDefinition = { content: [message] }; return pdfMake.createPdf(docDefinition); }}
Este código no funciona y en la clase My-Messages donde instalo esta clase, sigo recibiendo el siguiente error:
index-2022e853.js:2706 TypeError: Cannot read properties of undefined (reading 'pdfMake') at my-messages.entry.js:78239 undefined Uncaught (in promise) Error: Constructor for "my-messages#undefined" was not found at initializeComponent¿Cómo puedo solucionar este error?