ERROR while using pdfMake 0.2.15 - File 'Roboto-Medium.ttf' not found in virtual file system

Discussão em 'Angular' iniciado por hemant, Janeiro 17, 2025.

  1. hemant

    hemant Guest

    This code worked with pdfMake 0.2.12 (2 months back), However with pdfMake 0.2.15, it gives the following error

    ERROR: pdf.service.ts:43 ERROR File 'Roboto-Medium.ttf' not found in virtual file system

    pdfService.ts

    type PDFMake = typeof import('pdfmake/build/pdfmake')
    private pdfMake!: PDFMake;


    async generateOpenPdf(docDef: any) {
    await this.loadPdfMaker();
    this.pdfMake.createPdf(docDef).open();
    }


    async loadPdfMaker() {
    if(!this.pdfMake) {
    const pdfMakeModule = await import('pdfmake/build/pdfmake');
    const pdfFontsModule = await import('pdfmake/build/vfs_fonts');
    this.pdfMake = pdfMakeModule.default;

    // BELOW LINE WORKS in v0.2.12.
    // Compiler Error in 0.2.15: "Property 'pdfMake' does not exist on type 'typeof import("d:/Hemant/BA-WA/ca3/node_modules/@types/pdfmake/build/vfs_fonts")'"

    this.pdfMake.vfs = pdfFontsModule.default.pdfMake.vfs;


    // BELOW line does not give compiler error in v0.2.15
    // however, when generateOpenPdf method is executed it gives the error mentioned in subject.
    this.pdfMake.vfs = pdfFontsModule.default.vfs;
    }
    }



    The posts related to this topic are dated prior to two months and are not related to issue for v0.2.15. Anyone facing this issue?

    Continue reading...

Compartilhe esta Página