Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to import PDFmake in angular8?

i am trying to develop converting a angular form to PDF in my application , i have seen an example in stackblitz but when i try to follow the same code in my local, import are not working ? error is could not find the declaration for "pdfmake/build/pdfmake"

import pdfMake from "pdfmake/build/pdfmake";
import pdfFonts from "pdfmake/build/vfs_fonts";
pdfMake.vfs = pdfFonts.pdfMake.vfs;

Update: i have tried installing "@types/pdfmake" to fix this. it fixed partially but throwing error at "pdfmake.vfs" saying cannot assign to vfs because it is readonly property

import * as pdfMake from "pdfmake/build/pdfmake";
import * as  pdfFonts from "pdfmake/build/vfs_fonts";
pdfMake.vfs= pdfFonts.pdfMake.vfs;
like image 299
sravan ganji Avatar asked Sep 07 '25 04:09

sravan ganji


1 Answers

please try this, it works for me :

import * as pdfMake from "pdfmake/build/pdfmake";
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
(pdfMake as any).vfs = pdfFonts.pdfMake.vfs;
like image 163
bart-khalid Avatar answered Sep 10 '25 05:09

bart-khalid